Failover is the transfer of work from a component that has failed to one that is healthy. NIST defines it as switching over automatically, typically without human intervention. When teams start it by hand, AWS advises automating the steps anyway, so that starting it is like pushing a button. A runbook that has an engineer reconfigure providers mid-incident is manual recovery, and it is slow.
"The capability to switch over automatically (typically without human intervention or warning) to a redundant or standby system upon the failure or abnormal termination of the previously active system."
Source: NIST SP 800-53 Rev. 5, via the CSRC Glossary
For LLM systems, failover is unusually important because the dependency is external. You cannot fix a provider outage, add capacity to someone else's cluster, or roll back their deploy. The only available lever is sending the request somewhere else.
Failover, fallback, and failback
The three terms are easy to confuse, but they mean different things.
| Term | Meaning | Result quality |
|---|---|---|
| Failover | Switch to an equivalent healthy replacement | Same as normal |
| Fallback | Switch to a degraded but acceptable alternative | Reduced |
| Failback | Return to the original component once it recovers | Same as normal |
Routing from one API key to another key for the same model is failover: the result is identical. Routing from a frontier model to a smaller, cheaper one is a fallback: the request succeeds, but quality may drop. Serving a canned "try again shortly" message is graceful degradation, which is a fallback of last resort.
Failover can be silent. A fallback should be recorded, because the user got something different from what the system normally produces.
Failover topologies
The AWS disaster recovery whitepaper describes these options for regional failover.
| Topology | Standby state | Relative recovery time | Cost |
|---|---|---|---|
| Active-passive | Not serving until failover; may be fully provisioned (hot), scaled down (warm), or mostly off (pilot light) | Fast if the standby is running | Standby capacity sits unused |
| Active-active | Serving traffic continuously | Near zero | Fully utilized |
| Pilot light | Data and core infrastructure in place; app servers off until failover | Slowest: servers must start and scale first | Low |
For LLM providers, consider active-active as the default. On pay-as-you-go plans it is cheaper than it sounds, because with per-token billing a second provider in rotation costs only the traffic you send it. It also fixes the biggest weakness of active-passive, since a standby that never serves traffic is a standby you cannot trust. There are two exceptions. Reserved capacity, such as Azure provisioned throughput, is billed hourly whether used or not. And because provider prompt caches are per provider and usually per key, a conversation that hops between them misses the cache it warmed a turn ago.
Failover triggers
Not every error deserves a retry elsewhere. Failing over on the wrong signal wastes money and can amplify an outage.
| Response | Meaning | Correct action |
|---|---|---|
429 rate limited | Too many requests for this key or account in a time window; OpenAI also uses 429 for exhausted credit and spend limits | Back off on this key (honor Retry-After) and shift traffic to another key or backend |
500 / 502 / 503 / 504 (Bifrost also treats 529 as transient) | Backend is failing | Fail over |
| Timeout | Unknown, possibly still processing | Fail over, but beware duplicate work |
400 bad request | Usually a malformed request, though some providers return 400 for a bad key, empty credit, or model problem (Bifrost docs cite Gemini and Anthropic examples) | Don't resend the same request; fail over only if the error shows a key or account problem |
401 / 403 | Key rejected or not permitted; OpenAI also returns 403 for an unsupported country or region | Don't resend on the same key; rotate to another key if one exists, and alert |
| Content filter refusal | Deliberate provider policy decision | Treat as a valid answer, not an outage; don't resend to another provider |
Azure OpenAI, for example, rejects a filtered prompt with HTTP 400 and code content_filter, so check the error code, not just the status.
Two mistakes to avoid are failing over on 400, which burns a second provider's quota on a request that cannot succeed, and treating a content policy refusal as an outage, which quietly routes sensitive traffic to whichever provider has the loosest filters.
Retries, backoff, and circuit breakers
Failover is one layer of a resilience stack, and the layers must cooperate.
Retries handle transient blips on the same backend. They need a bounded attempt count and exponential backoff with jitter, as detailed in the AWS Builders' Library article on timeouts, retries, and backoff with jitter. Without jitter, clients that back off to the same time collide again and recreate the overload.
Circuit breakers stop sending traffic to a backend that is consistently failing. Rather than paying the timeout cost on every request, the breaker opens and fails fast, then periodically probes for recovery. Martin Fowler's Circuit Breaker article and the Azure circuit breaker pattern both describe the closed, open, and half-open states.
Retry budgets cap retries as a share of total traffic, so retries can't turn a partial outage into a total one. Google's SRE book describes a per-client budget of about 10% in Handling Overload and a per-process cap in Addressing Cascading Failures.
Retries multiply across layers. Google's SRE book works through the math: if three layers each retry three times (four attempts each), one user action can produce 64 attempts against the backend. Retry logic belongs in exactly one layer.
Differences between LLM and standard failover
Standard failover assumes replicas are interchangeable. Model providers are not.
- Different API shapes. Provider request and response formats differ, so failing over requires translation. That argues for doing it at a gateway that already normalizes to one schema.
- Capability mismatch. The secondary may not support the same context length, tool-calling format, structured output mode, or modalities. A fallback that cannot honor the request's requirements will fail differently rather than succeed.
- Cost differences. Failing over to a more expensive model during an outage can produce a surprising bill. Budgets should apply to fallback paths too.
- Non-deterministic output. Even a successful failover yields different text than the primary would have. Anything caching or diffing responses must tolerate that.
- Partial failure during streaming. If a provider dies mid-stream, tokens have already reached the user. Restarting on another provider means either discarding visible output or stitching a response from two models.
Testing failover
Failover logic runs rarely, and only after something has already gone wrong, so an untested path is likely to fail at the moment it is needed.
Practical verification:
- Inject faults. Return errors from a provider on purpose and confirm traffic moves. Bifrost ships a mocker plugin that mocks provider responses for testing and simulation.
- Exercise secondaries continuously. Route a small percentage of production traffic to them so they are never cold.
- Measure how long failover takes end to end, including timeouts. A 60-second timeout before failover is a 60-second stall the user sees.
- Verify capability parity. Test that fallback models handle your tool schemas and output formats, not just that they return a
200.
Failover at the gateway
Implementing failover per application means every service carries provider SDKs, health state, retry logic, and credentials, and each one learns about outages independently.
Centralizing failover at the AI gateway changes that. Health state is shared, so one service detecting a failure protects all of them immediately. The gateway already normalizes providers to a single API, so cross-provider failover needs no application changes. Retries live in one layer, which avoids the multiplication described above as long as client SDK retries are turned off. Every failover is logged in one place, so you can see how often you are silently serving a degraded model.
Bifrost implements ordered retries and fallbacks across providers and models. Enterprise scalability covers the circuit-breaker thresholds (above 2% errors marks a provider degraded, above 5% failed), and AWS Bedrock + Bifrost describes multi-region fallback chains such as Bedrock us-east-1 to us-west-2. Applications keep calling the same endpoint:
Key takeaways
- For token-billed model APIs, prefer active-active, because a second provider costs only the traffic you send it and never sits untested. Reserved capacity and prompt caching are the exceptions.
- Fail over on
5xxand timeouts, shift traffic on429, rotate keys on401/403, and don't resend malformed requests or content-filter refusals to another provider. - Keep retry logic in exactly one layer, use backoff with jitter, and add a circuit breaker so failing backends fail fast.
Sources and further reading
- NIST CSRC Glossary: failover
- AWS: Disaster recovery options in the cloud
- OpenAI API docs: Error codes
- AWS Builder Center: Timeouts, retries, and backoff with jitter
- Google SRE Book: Handling Overload
- Google SRE Book: Addressing Cascading Failures
- Martin Fowler: Circuit Breaker
- Microsoft Learn: Circuit Breaker pattern
- Microsoft Learn: Azure OpenAI content filtering
- Microsoft Learn: Provisioned throughput billing
- IETF RFC 6585: Additional HTTP Status Codes
- Rubrik: The difference between failover and failback
- Bifrost Docs: Retries & Fallbacks
- Bifrost Docs: Routing (Virtual Keys)
- Bifrost Docs: Circuit Breaker
- Bifrost Docs: Adaptive Routing
- Bifrost Docs: Session Affinity
- Bifrost Docs: Mocker plugin
- Bifrost Docs: OpenAI SDK integration
- Bifrost Docs: Drop-in Replacement
- Bifrost: Enterprise AI Gateway for Scalability
- Bifrost for AWS Bedrock