UPROUTERONLINE
Connect & Resilience

Building Resilience: Failover & Redundancy Across AI API Providers

Uprouter Editorial5 min read
"failoverredundancyresiliencehaarchitecture"

Building Resilience: Failover & Redundancy Across AI API Providers

AI APIs fail. Providers have outages, rate-limit spikes, region-level incidents, and the occasional deprecation that catches you off guard. If your product depends on one provider for one model, that provider's incident timeline is now your incident timeline. The goal of failover and redundancy is simple: no single provider outage should be able to take your product down.

Here's a practical architecture for getting there.

The core idea: candidates, not a single target

Instead of "call provider X," you define an ordered list of candidate providers/models for a logical capability. A request tries the first candidate; if it fails or times out, the request is retried against the next. The user sees one capability ("answer this prompt"); you see several interchangeable backends.

This is exactly the pattern routers formalize — a routing alias maps a friendly name (like fast or reasoning) to an ordered set of candidates and a strategy for picking among them. You can build this yourself, or use a router that does it for you. The design principles are the same either way.

1. Decide the failover trigger

You have to define what counts as "failed" and triggers the next candidate. The common signals:

  • HTTP error — 5xx, 429 (rate-limited), 408 (timeout).
  • Latency budget exceeded — the request took longer than your SLO allows.
  • Malformed or empty response — a 200 that isn't usable.
  • Local health probe — a background check that flags a provider as degraded before user traffic hits it.

Be explicit about this. "Fail over on error" without defining the latency budget will fail over too late — the user already felt the stall.

2. Set a timeout budget per hop

The most common resilience bug is unbounded retries. If each candidate can hang for 30 seconds and you have four candidates, one request could take two minutes. Instead:

  • Give each candidate a per-hop timeout sized to your SLO.
  • Make the total budget the sum of what the user can tolerate, and fail fast once it's exhausted.
  • Consider deadline propagation — pass a shrinking deadline to each candidate so later retries get less time, not the full budget.

A short, smart timeout that fails over quickly usually beats a long timeout that eventually succeeds but after the user gave up.

3. Choose a selection strategy

When you have multiple healthy candidates, which one does a request go to?

  • Ordered — always first-then-next. Predictable, good for cost (cheapest first) or quality (best first).
  • Cheapest-first — rank by cost; fall to the next only on failure. Good for cost control.
  • Latency-based — rank by recent measured latency. Good for interactive apps.
  • Weighted / load-balanced — spread traffic to reduce concentration on one provider.

You can combine these: "cheapest healthy first, fail to the most reliable." The key is that the strategy uses fresh signals (current price, current latency, current health), not a static preference. The model index and directory are where you find the current per-provider numbers to feed a strategy like this.

4. Keep candidates truly independent

Redundancy only works if the failures are independent. Two candidates that share the same upstream (e.g., two routers both reselling the same single vendor) fail together. For real resilience:

  • Spread candidates across different providers, ideally different companies and regions.
  • Avoid concentrating on one vendor's model family if you can — a single model's deprecation or incident shouldn't be fatal.
  • Remember a router is itself a candidate that can fail; don't make the router your only path. Keep a direct provider as a last-resort fallback.

5. Add the cheap resilience layers first

Before complex failover, a few low-cost layers absorb a surprising amount of failure:

  • Retry with backoff on transient errors (429, 503) — but bounded, and only for idempotent-safe requests.
  • Timeouts + circuit breaker — stop hammering a provider that's clearly down for a cool-down window.
  • Caching — serve a cached or previously-generated response for repeated prompts, and use it as a graceful-degraded fallback. See prompt caching for the cost side.
  • Graceful degradation — if the ideal model is down, fall back to a smaller/cheaper model that's "good enough," rather than nothing.

6. Observe it, or it doesn't exist

Failover you can't see is failover you can't trust. Instrument it:

  • Log which candidate actually answered each request, and the latency.
  • Alert on failover rate — a spike means a candidate is struggling before it's fully down.
  • Track per-provider health over time (the same reliability lens you'd apply when choosing).
  • Re-test your fallbacks regularly — a path you've never exercised in a real outage tends to be broken when you need it.

The bottom line

Resilience across AI providers is candidates + explicit failover triggers + bounded timeouts + a selection strategy on fresh signals + genuinely independent backends, wrapped in retry/caching/circuit-breaker layers and backed by observability. Do that and a single provider outage is a blip instead of an incident. Skip any of it and you're betting your uptime on someone else's status page.

Related reading

FAQ

What's the simplest way to add failover to an AI app? Define an ordered list of candidate providers/models for each capability, and on error or timeout retry the next one — with a bounded per-hop timeout. That single change means one provider's outage doesn't stop your product.

Why is a timeout budget so important? Without it, retries stack up and one request can hang for minutes across several candidates. Set a per-hop timeout and a total budget sized to your user SLO, and pass a shrinking deadline so later retries get less time.

Does two providers equal real redundancy? Only if the providers are independent. Two services reselling the same single upstream fail together. Spread candidates across different companies/regions, and keep at least one direct provider as a last resort.

Should I keep a router as my only path? No — a router is itself a component that can fail. Use a router for convenience and failover among its candidates, but keep a direct provider relationship as a fallback so the router isn't a single point of failure.

// related

Uprouter command palette

Jump to a page, provider, model or action

Keyboard shortcuts

Every keyboard shortcut available on Uprouter