Search⌘ K
AI Features

Model Routing and Automatic Fallbacks

Explore how OpenRouter improves AI system resilience by automatically routing around provider outages and failures. Learn to configure fallback strategies and implement client-side retries to keep your application reliable even during disruptions.

In the last lesson, we learned how to programmatically find the best model for any task. The next concern in a production environment is uptime: a model choice is only as reliable as the provider serving it. OpenRouter addresses this directly by automatically routing around provider failures.

This lesson is about building resilience. We will explore how OpenRouter acts as a safety net, automatically routing around provider failures to keep your application running reliably.

The problem of provider downtime

For many popular models, especially open-source ones, OpenRouter integrates with multiple providers that serve the same model. For example, meta-llama/llama-3.1-70b-instruct might be available from providers like Together, Fireworks, and Groq simultaneously.

Hardcoding your application to use just one of those providers means any API errors, high latency, or outage on their end becomes your application’s downtime. ...