Overview
Model fallback enables specifying multiple models in amodels array. The API tries each model in order until one succeeds, providing automatic failover when a model is unavailable.
How It Works
Provide amodels array containing up to 5 models:
- The API tries the first model in the array
- If it fails or is unavailable, the next model is tried
- This continues until one succeeds or all models are exhausted
models array takes precedence over the single model field when both are provided.
Benefits:
- Higher availability: Automatic failover when primary model is unavailable
- Provider redundancy: Use models from different providers for maximum reliability
- Seamless operation: No code refactoring needed, fallback is handled automatically by the API
Basic Example
Cross-Provider Fallback
For maximum reliability, use models from different providers:Pricing
Themodel field in the response indicates which model was used, and the usage field shows the token counts for that model.
Example
Example
Request:Response (if first model failed):In this case, billing is based on
gpt-5.1 pricing for 470 tokens.Next Steps
Models
Explore available models and their pricing.
Presets
Explore available presets and their configurations.
Agent API Quickstart
Get started with your first Agent API call.
API Reference
View complete endpoint documentation.