Beta: The LLM Gateway is in beta.
How it works
A fallback configuration has:- A name: exposed at the route
https://gateway.smith.langchain.com/routes/{name}. Clients call this URL instead of a provider-specific path. - One or more fallback chains: each an ordered list of model configurations to try in priority order.
- Triggers: the upstream HTTP status codes that should cause the gateway to move on to the next model in the chain. For example,
429for rate limits, or500,502,503,504for other provider errors.
- Determines the wire format from the request path, and considers only the chains in that format (see Wire formats).
- Picks one of those chains (see Selecting a chain).
- Calls the chain’s first model configuration.
- If the response status matches a configured trigger, discards that response and calls the next model configuration in the chain.
- Repeats until a candidate returns a non-trigger response, or the chain is exhausted—in which case the last candidate’s response is returned to the caller.
Wire formats
Each chain is either OpenAI-compatible or Anthropic-compatible, since the gateway forwards the same request body to every candidate in it:
Only these two provider types can go in a chain. A model configuration saved for another provider, such as Azure OpenAI or Bedrock, isn’t eligible. To reach a host that speaks the OpenAI API, save it as an OpenAI Compatible Endpoint with its base URL.
The path you call selects the format, and the gateway only considers chains in that format. Any other path returns
501 Not Implemented.
A single fallback configuration can hold chains of both wire formats, so one route can serve both OpenAI-compatible and Anthropic-compatible clients. Mixing formats is optional: a configuration with only OpenAI-compatible chains returns 502 for /v1/messages calls, and one with only Anthropic-compatible chains returns 502 for /v1/chat/completions calls.
Create a fallback configuration
- Go to Settings → Gateway → LLM Gateway and select the Model Fallbacks tab.
- Click Create configuration.
- Enter a Configuration name. This becomes
{name}in the gateway URLhttps://gateway.smith.langchain.com/routes/{name}. - Select the Workspace the configuration belongs to. Model configurations are workspace-scoped, so only that workspace’s configurations are available to add to a chain. The workspace can’t be changed later—delete and recreate the configuration to move it.
- Under Fallback triggers, review the HTTP status codes that should trigger a fallback. The list comes prepopulated with the transient codes another provider has a chance of serving (such as
429,500, and503); add or remove codes as needed. - Under Model fallback chains, click Add chain, then add two to five model configurations in the order the gateway should try them. A chain’s first model fixes its wire format; only configurations of that format can follow. The gateway groups chains by format, and the first chain in each group is that format’s default, which it uses when a request’s model does not select another chain.
- Click Create configuration.
Make a call
Call the route the same way you’d call a custom provider, on the path for the wire format you want:Selecting a chain
A configuration can hold more than one fallback chain, which is useful when different model families need different fallback behavior. Among the chains matching the request’s wire format, the gateway selects one by the request body’smodel field, in this order:
- If
modelmatches a chain’s alias, that chain is used. - Otherwise, if
modelmatches a chain’s primary (first) model configuration’s underlying model name, that chain is used. - If
modelis omitted, or matches neither, the first (default) chain of that format is used.
"model": "heavy" without knowing which model backs it.
Each model configuration in a chain can point to a different host, so a chain can fail over across separate deployments of the same model (for example, from a primary endpoint to a backup) with no single host as a point of failure.
For example, a configuration with three chains:
- A
/v1/chat/completionsrequest with"model": "gpt-5.5"uses chain 1, which fails over from OpenAI to Azure OpenAI to the self-hosted endpoint. - A
/v1/chat/completionsrequest with"model": "gpt-4o-mini"uses chain 2, which fails over from OpenAI to Fireworks. - A
/v1/chat/completionsrequest with an unrecognized or omitted model uses chain 1, the default for that format. - A
/v1/messagesrequest uses chain 3 whatever itsmodelis, because it’s the only Anthropic-compatible chain. Chains 1 and 2 are never eligible on that path.
Next steps
- Custom model providers: call the same model configurations directly, one at a time, without a fallback chain.
- Spend policies: apply cost limits alongside fallback routing.
Connect these docs to Claude, VSCode, and more via MCP for real-time answers.

