Your AI Failed Over to a Model You Never Tested

Table of Contents
Somewhere in your stack there is a model you have never tested, and it is already serving users. It’s the second entry in your gateway’s fallback list — the one that takes over when the primary provider rate-limits, 500s, or trips a moderation filter. Your evals pin the primary. Your Playwright suite hits the primary. Your golden dataset was scored against the primary. The backup model is production code with zero test coverage, and the only thing standing between it and your customers is an outage you don’t control.
That outage is not hypothetical. Anthropic’s API went down on July 29, 2026 — elevated errors from 19:45 UTC, resolved at 22:36 UTC, with a user-visible window of 1 hour and 41 minutes. OpenAI’s API failed globally on July 25, taking ChatGPT, the developer API, and Codex with it, and logged 11 separate incidents in a 28-day window in January 2026. An API reliability survey covering 215+ services put AI and ML APIs dead last, with more incidents per service than any other tracked category. Every one of those windows is a period where your app was answering users with a model your test suite has never seen.
1h41m
User-visible impact
Anthropic API outage, July 29 2026
11
OpenAI incidents
In 28 days, January 2026
last
AI/ML API reliability
Of 215+ services surveyed
Why does the fallback model ship untested?
Because failover is configured by the platform team and tested by nobody. It lives in a gateway config file, not in application code, so it never shows up in a pull request that a QA engineer reviews. LiteLLM ships three separate failover types — fallbacks for general errors, context_window_fallbacks for token-limit errors, and content_policy_fallbacks for moderation refusals — plus default_fallbacks that catch anything a model-specific rule missed. OpenRouter’s models array triggers on downtime, rate limits, context-length errors, and moderation flags by default. Nobody has to opt in to any of this for it to be live.
The second reason is that a successful failover looks identical to a successful request. Same 200, same response shape, same happy user-facing spinner. The gateway did its job: it kept the request alive. What it cannot do is keep the request equivalent, and equivalence is the thing your assertions were quietly built on.
model_list: - model_name: policy-summarizer litellm_params: { model: openai/gpt-5-primary } - model_name: policy-summarizer-backup litellm_params: { model: openai/gpt-4o-mini }
litellm_settings: num_retries: 3 fallbacks: [{ "policy-summarizer": ["policy-summarizer-backup"] }] default_fallbacks: ["policy-summarizer-backup"] # catches everything else cooldown_time: 30Ten lines, one PR, reviewed by a platform engineer at 4pm on a Friday. That config is now a second product surface.
What actually changes when the backup model serves?
More than latency and price. The backup differs on every axis your feature silently depends on, and each difference maps to a specific assertion you probably don’t have.
| What changes | How it fails | The assertion you’re missing |
|---|---|---|
| Strict JSON schema support | Structured fields arrive as prose | Parse the response, not just render it |
| Context window size | Long inputs cascade to a third model | Assert on a max-length fixture |
| Tool-calling format | Wrong arg names, dropped calls | Assert the tool call, not the reply |
| Refusal threshold | Legitimate requests get declined | Run your over-refusal corpus on the backup |
| Time to first token | Retries stack before the fallback fires | Gate TTFT on the failover lane too |
| Price per token | Fallback can cost more, not less | Track spend by served model |
The structured-output cliff
This is the one that bites hardest, because it’s binary. Schema support is not uniform across providers: OpenAI, Gemini, and Azure each accept a different subset of JSON Schema, while Claude expresses structured output through tool definitions with input_schema rather than a matching response_format strict mode. Frameworks paper over it — LangChain falls back to a tool-calling strategy when a model has no native structured output — and that papering-over is exactly where the guarantee quietly downgrades from enforced by the decoder to usually produced by the model.
Your UI doesn’t know the difference. It renders whatever came back. A field that used to be a constrained number is now a sentence, your parser writes a null, and the page shows an empty state that looks like missing data rather than a broken model.
The context-window cascade
Failover is not one hop. If the backup has a smaller window, a long input that succeeded on the primary now raises a context-length error at the backup — which is itself a fallback trigger, so the gateway hops again, to a third model nobody has evaluated at all. LiteLLM only enforces window limits before the call if you set enable_pre_call_checks: true; without it, requests go to the provider regardless of input size and you discover the ceiling as a runtime error mid-outage. Any test fixture built from short, tidy prompts will never reach the edge that triggers this.
I watched this play out at a large North American insurer. Their policy-summarization feature emitted a strict JSON object — deductible, coverage limit, exclusions — that the UI rendered into a table. The gateway’s default_fallbacks pointed at a cheaper model without strict schema support. Over a 19-day stretch, retries and rate limits pushed 6.4% of production calls onto that backup, which returned coverage figures as prose. The parser wrote nulls. 1,847 policy summaries rendered with an empty deductible field, and every single request logged a 200. The eval suite ran nightly and stayed green the entire time, because it called the model by its pinned name and never went through the gateway’s failover path. Detection came from a broker’s support ticket on day 19. Mean time to detect: 19 days, for a bug that a single test could have caught in 40 seconds.
How do you force a failover in Playwright?
Make the failed provider a test input, not an accident. You need two lanes running the same specs: one against the primary, one where the primary is guaranteed to fail. The clean way is a dedicated Playwright project that flags the request path, with your BFF translating that flag into a gateway route where the primary deployment always errors.
Don’t reach for the framework’s built-in mock flag without checking its status first — LiteLLM’s mock_testing_fallbacks is stripped from incoming Proxy requests as of v1.85.0 and now works only for direct Router calls in unit tests. For E2E, configure a deliberately-failing deployment in a test-only gateway config instead. This is the same fault-injection discipline I argue for when your agent’s tools never fail in CI — a resilience path you can’t trigger on demand is a resilience path you can’t verify.
export default defineConfig({ projects: [ { name: 'primary', use: { ...devices['Desktop Chrome'] } }, { name: 'failover', use: { ...devices['Desktop Chrome'], extraHTTPHeaders: { 'x-chaos-provider': 'primary-503' }, }, grep: /@failover/, // only specs that assert the degraded contract }, ],});How do you prove the test actually hit the fallback?
Assert on the model that served the response, because a failover test that silently ran on the primary is worse than no test — it’s a green check on an unexercised path. Every layer already exposes this. OpenRouter returns the model that ultimately ran in the model attribute of the response body, and prices the request against it. LiteLLM returns the deployment in the x-litellm-model-id header. OpenTelemetry’s GenAI conventions split the two explicitly: gen_ai.request.model is what you asked for, gen_ai.response.model is what answered.
Surface it on your own API response, then capture it in a fixture:
export const test = base.extend<{ servedModel: () => string | undefined }>({ servedModel: async ({ page }, use) => { let served: string | undefined; page.on('response', (res) => { if (!res.url().includes('/api/summarize')) return; // BFF forwards the gateway's answer: OpenRouter body `model`, // or LiteLLM's `x-litellm-model-id` header. served = res.headers()['x-served-model'] ?? served; }); await use(() => served); },});Now the degraded-path spec has teeth. Three assertions, in this order: the failover happened, the contract held, and the user was told.
test('@failover coverage summary stays structured on the backup', async ({ page, servedModel }) => { await page.goto('/policies/PL-4821'); await page.getByRole('button', { name: 'Summarize coverage' }).click(); await expect(page.getByTestId('coverage-deductible')).toBeVisible();
expect(servedModel()).not.toBe(PRIMARY_MODEL); // the lane is real await expect(page.getByTestId('coverage-deductible')) .toHaveText(/^\$[\d,]+$/); // schema survived await expect(page.getByTestId('degraded-notice')).toBeVisible();});Before
The request returned 200
After
The backup model served it and held the contract
That not.toBe(PRIMARY_MODEL) line is the whole trick. Without it, the day someone fixes the chaos header, your failover suite keeps passing forever against the primary and you never find out. It’s the same class of self-verification I use when correlating a Playwright failure back to the exact prompt that caused it: the test has to prove which system under test it actually touched.
What runs per PR versus during an outage drill?
Per PR — the failover contract lane
Run the @failover project on every pull request. These specs are deterministic: the primary always fails, the backup always serves, and you’re asserting on your parsing and disclosure logic. No live-model flake, because the assertion is structural, not semantic.
Per PR — the max-length fixture
One spec with an input sized just under the primary’s window and over the backup’s. It should fail loudly or route deliberately, never cascade silently to a third model.
Nightly — the backup's own eval set
Run your golden dataset against the backup model, not just the primary. Model-quality regression on a fallback is still a production regression; the same drift gate you run on model upgrades belongs on every model in the routing table.
Nightly — refusal and latency on the degraded path
Replay your over-refusal corpus against the backup, and re-run the time-to-first-token gate on the failover lane — retries stack before the fallback fires, so the user-perceived latency is primary timeout plus backup TTFT, not backup TTFT alone.
Quarterly — the real drill
Disable the primary in staging for 30 minutes and watch dashboards, cost, and alerts. Gateways add cooldowns on top of fallbacks — LiteLLM’s default cooldown_time, OpenRouter deprioritizing any provider with an outage in the last 30 seconds — so recovery behavior has its own shape worth seeing once.
One cost note people get backwards: failover does not reliably save money. OpenRouter prices the request against the model that ultimately ran, so a fallback aimed at a larger model during a primary outage bills at the higher rate, on top of the retries you already paid for. If your rate-limit handling and your failover config were written by different people at different times — and they were — read them together with what happens when parallel tests trip the 429 ceiling.
Your one next step this week
Open your gateway config and write down every model in the routing table, including default_fallbacks. Then take the single highest-stakes structured output your product produces and run its existing E2E spec once with the primary forced to fail, asserting servedModel() !== PRIMARY. If the spec passes, you have real failover coverage. If it fails — and on most stacks I’ve audited it fails on the first run, usually on a field that stopped being a number — you just found a production bug that was waiting for someone else’s outage to reach your customers.
How do I know which model actually served a request?
Every layer exposes it. OpenRouter returns the model that ultimately ran in the model attribute of the response body and prices the request against it. LiteLLM returns the deployment in the x-litellm-model-id response header. OpenTelemetry’s GenAI conventions separate gen_ai.request.model from gen_ai.response.model. Surface that value on your own API response so tests and dashboards can both assert on it.
Why isn't a 200 response enough to prove failover worked?
Because the gateway’s job is to keep the request alive, not to keep it equivalent. A successful failover returns the same status code and response shape as a normal call — while the backup may not support strict JSON schema, may have a smaller context window, may format tool calls differently, and may refuse requests the primary allowed. The status code tells you the request survived; it says nothing about your contract.
Can I use LiteLLM's mock_testing_fallbacks flag in end-to-end tests?
Not through the proxy. As of LiteLLM Proxy v1.85.0, mock_testing_fallbacks, mock_testing_context_fallbacks, and mock_testing_content_policy_fallbacks are stripped from incoming proxy requests and have no effect — they remain supported only for direct litellm.Router calls in unit tests. For E2E, point a test-only gateway config at a deployment that always errors and drive it from a Playwright project.
Should the failover suite run on every pull request or nightly?
Both, split by what they assert. The contract lane belongs on every PR: it’s deterministic and tests your own parsing and disclosure logic with no live model involved. Model-quality checks on the backup — golden dataset, refusal corpus, time-to-first-token — belong in a nightly lane, because they call real models and shouldn’t gate a merge.
Does falling back to a backup model save money during an outage?
Not necessarily. OpenRouter prices the request using the model that ultimately ran, so a fallback list pointing at a larger or pricier model bills at that rate — on top of the retries against the failing primary that preceded it. Track spend by served model rather than requested model, or an outage shows up as a cost spike you can’t explain from your routing config alone.
