LlamaIndex
LlamaIndex is the retrieval and document
workflow framework. Use its OpenAILike LLM, which is the OpenAI client with
the model allowlist removed so arbitrary model IDs work.
Code
Setup guide: this config comes from LlamaIndex's official documentation and has not been run end to end against the gateway. Corrections to support@hyphen-solution.com.
The model
Code
Note it is api_base, not base_url. LlamaIndex kept the older name.
The last three kwargs are not optional in practice:
is_chat_model=Trueroutes to/v1/chat/completions. Leave it off and LlamaIndex uses the legacy completions path, which the gateway does not serve.is_function_calling_model=TrueunlocksFunctionAgentand tool calling. Hyphen supports tools, so this is correct.context_windowtells LlamaIndex how much it can pack into a prompt. 200000 suits the standard M-series. Use 4000000 forminimax-text-01and 66000 forminimax-m2-her.
Chat and streaming
Code
An agent with tools
FunctionAgent is async only, and it requires
is_function_calling_model=True on the LLM.
Code
Swap FunctionAgent for ReActAgent (same import path, same .run()) if you
would rather drive tools through prompting than native tool calls.
Using it as the global default
Code
Every index, query engine and agent then uses Hyphen without being passed the LLM explicitly.
Embeddings are not on the gateway
This is the easy one to miss. A VectorStoreIndex needs an
embedding model, and the Hyphen catalog has none. Set Settings.embed_model to
a local model or another provider:
Code
Retrieval runs locally, generation runs on Hyphen. That split is usually what you want anyway, since embedding a corpus is cheap locally and repeated.
Gotchas
api_base, notbase_url.max_tokensof 2000 or more. 4000 for agents. See Choosing a model.- Long documents: switch the model to
minimax-text-01andcontext_windowto 4000000. See Long-context work. 429means the monthly budget is spent. See Handling the 429 cap.
Related
- OpenAILike reference
- LlamaIndex agents
- Long-context work: feeding it a whole book.