Repository navigation
OpenAILike for OpenAI-compatible gateways: the two flags that matter (is_chat_model, is_function_calling_model) and the errors you get without them #23760
apigoto
started this conversation in
Show and tell
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
I work on the APIGOTO team. APIGOTO is an independent OpenAI-compatible gateway, not affiliated with OpenAI, Anthropic or Google. Nothing below is specific to us: it applies to vLLM, LM Studio, LiteLLM or any hosted endpoint that speaks
/v1/chat/completions. The point is three errors that keep showing up in issues when people point LlamaIndex at a non-OpenAI base URL.Why not
OpenAI(api_base=...)?llama_index.llms.openai.OpenAIlooks up the model name in its own table to get the context window and capabilities. With a gateway model ID it fails withUnknown model ... Please provide a valid OpenAI model name.OpenAILikeskips that lookup, and you declare the metadata yourself.Install
The LLM
Error 1: 404 on
/completionsis_chat_modeldefaults toFalse. Then evenllm.chat(...)flattens your messages into a prompt and calls the legacy/completionsendpoint, which most gateways and chat-only models don't serve. Setis_chat_model=True.Error 2:
ValueError: LLM must be a FunctionCallingLLMFunctionAgentchecksllm.metadata.is_function_calling_modelbefore its first step. With the defaultFalse, it refuses to run:If the model has no reliable tool calling, leave the flag
Falseand useReActAgentinstead. It drives tools through plain text, so it doesn't need function-calling support.Error 3: silent truncation
With
context_windowleft at 3900, the prompt helper packs retrieved chunks for a 3900-token window. Nothing fails, but answers ignore most of your context. Set the model's real window.Embeddings (only if your endpoint serves them)
Check
/v1/modelsfor an embedding model first. If there is none, keep a local embedding model and use the gateway only for the LLM.Two details: it takes
model_name(passingmodelraises an error), and itsmax_retriesdefaults to 10, compared with 3 for the LLM. Lower it if your gateway already retries.Retries
Our gateway retries a failed upstream call on another route, at most 3 times. LlamaIndex retries on top of that, so
max_retries=1on the client keeps worst-case latency predictable. Per-request logs on the gateway side show which retry actually answered. Pay-as-you-go, BYOK supported: www.china-aiapi.comHas anyone hit a case where
OpenAILikeResponsesbehaves better thanOpenAILikeagainst a third-party endpoint?All reactions