Add fallback models
Set the primary model withmodel. Set fallback models with models.
gpt-4o first. If that request fails with a rate limit, an auth error, a server error, or a timeout, it tries each entry in models in order until one succeeds. Other 4xx errors, such as an invalid request, return right away. See what triggers failover.
Choose the provider for each fallback
Fallback models can use model IDs orprovider:model.
Fall back from a private model to a hosted model
Fallback works with custom providers, too.my-ollama provider first. If that request fails, it falls back to OpenAI.
Choose fallback models carefully
Pick fallback models that can handle the same kind of request as the primary model. Check each model for:- Input modality.
- Tool calling support.
- Output size.
- Context window.
- Latency expectations.
- Provider credentials.
Access restrictions still apply
Fallback models must be allowed by the access key configuration assigned to the access key. If a fallback model isn’t allowed, the gateway skips it and names it in theNgrok-AIG-Rejected-Models response header. The request still runs with the models that are allowed. It fails only when none of the models you listed are allowed.
Next steps
- Choose a model: Choose a model by ID or provider
- Automatic model selection: Let ngrok.ai pick the model instead. Don’t combine it with
models - Restrict providers and models: Limit what an access key can call
- Model catalog: Compare model capabilities