Model Fallbacks
The models parameter lets you automatically try other models if the primary model’s providers are down, rate-limited, or refuse to reply due to content moderation.
How It Works
Provide an array of model IDs in priority order. If the first model returns an error, OpenRouter will automatically try the next model in the list.
Fallback Behavior
If the model you selected returns an error, OpenRouter will try to use the fallback model instead. If the fallback model is down or returns an error, OpenRouter will return that error.
By default, any error can trigger the use of a fallback model, including:
- Context length validation errors
- Moderation flags for filtered models
- Rate-limiting
- Downtime
Pricing
Requests are priced using the model that was ultimately used, which will be returned in the model attribute of the response body.
Using with the Anthropic Messages API
The Anthropic Messages API endpoint (/api/v1/messages) accepts the fallbacks parameter, matching the shape used by Anthropic’s SDKs. Each entry names a fallback model to try in order, and the list maps to OpenRouter’s models routing, so fallbacks trigger on the same errors listed above (rate limits, downtime, moderation refusals), not only on refusals.
OpenRouter handles this fallback routing itself. The fallbacks parameter does not use Anthropic’s server-side fallback feature.
Limitations
- Each
fallbacksentry accepts only themodelfield. Per-attempt overrides such asmax_tokens,thinking,speed, oroutput_configare rejected with a 400 error. fallbackscannot be combined with themodelsparameter; sending both returns a 400 error.fallbacksaccepts at most 3 entries; longer lists return a 400 error.
Using with OpenAI SDK
To use the models array with the OpenAI SDK, include it in the extra_body parameter. In the example below, ~openai/gpt-latest will be tried first, and the models array will be tried in order as fallbacks.