Free · Daily brief + weekly playbookDaily 60-sec AI Voice Brief + Weekly Production AI Agent PlaybookGet the brief →
ReleaseAPI / Product · ActionableHabr AI→ original

Five Hours of LLM API Downtime a Month: How to Build a Fallback Without Losing Meaning

The average uptime of LLM providers is 99.28%, meaning roughly five hours of unavailable API per month. A second key for handling a 500 error saves availability, but not meaning: a different model handles JSON schemas, tool calls, and prompts differently. The author of the Habr analysis recommends a cascade: retries, then a different deployment, then a different model, and only then a different provider. The backup response should be checked against the schema and by a judge model. That way, the user notices neither the failure nor any drop in quality.

AI-processed from Habr AI; edited by Hamidun News
Five Hours of LLM API Downtime a Month: How to Build a Fallback Without Losing Meaning
Source: Habr AI. Collage: Hamidun News.
Listen to article
Article Fact Sheet & Key Figures
ParameterDetails
Primary sourceHabr AI ↗
Editor-in-Chief
LiteLLMseparate fallback lists for context overflow and moderation
Key metric #2OpenRouter accepts a list of models directly in the request body
Key metric #3Retrying 400/401/403/404 errors is pointless: the fault lies in your code

If your customer chat, document generator, or agentic system relies on one or two API endpoints, then when the provider goes down, your product goes down with it. This is not theory: according to an independent report from ModelUptime, the average uptime of LLM providers is 99.28%. That sounds decent, but it amounts to roughly five hours of unavailable API every month. And according to a review of AI provider outages in 2026, OpenAI averaged one incident every 2.5 days at the start of the year. Moreover, an incident is not always a complete outage: often it is simply degraded quality.

Why a second key doesn't solve the problem

The standard answer is to set up a second API key and switch to it when the first returns a 500. You will save availability, but not the meaning of the response. Another model, even one "of the same class," writes differently, handles JSON schemas and tool calls differently, and interprets your prompts differently. The application will keep running, but with someone else's text that nobody has checked against expectations set by the primary model.

The author of the Habr analysis distinguishes two concepts. Retry means making another attempt at the same place, expecting a temporary problem. Fallback means switching to an alternative path when the problem won't go away on its own.

The cascade and error types

Fault tolerance is built as a pyramid, where each next level is more expensive and riskier:

  • retry with exponential backoff and random jitter, which only fixes short-lived failures;
  • a different deployment of the same model, for example GPT on Azure as primary and OpenAI directly as backup, where the response format stays the same;
  • a different model from the same provider, say from Claude Sonnet to Haiku, which is cheaper but behaves differently;
  • an entirely different provider, which gives maximum resilience and maximum risk of losing meaning.

The response depends on the error type. Timeouts, dropped connections, and 502/503 errors should be retried first, then switched. A 429 rate limit should be retried with the Retry-After header taken into account, but if you hit a daily quota, you need a different provider. Code 529 from Anthropic means the provider is at fault, and it is the cleanest trigger for a fallback. A context overflow error requires a model with a known larger window or preliminary compression of the request. Moderation refusals require a provider with a different policy, especially in medicine, finance, and law. Errors 400/401/403/404 are pointless to retry: your own code needs fixing.

Tools: LiteLLM, OpenRouter, Portkey, and your own code

LiteLLM is the most flexible option if you want to keep the logic in-house. It works both as a library and as a proxy with a single OpenAI-compatible endpoint. It supports general fallbacks, separate context_window_fallbacks and content_policy_fallbacks, cooldown (after N failures a deployment drops out of rotation for a while), on-the-fly fallback management via API, and budget checks before switching to an expensive model. The cost is maintenance: versions, updates, the issue tracker.

OpenRouter accepts a priority-ordered list of models directly in the request body and triggers on outages, limits, context overflow, and moderation. The limitation is obvious: you are tied to the aggregator and its routing rules.

Portkey is a managed gateway where the fallback is defined by a config on the platform side. The switching target can be a load balancer, a conditional router, or a nested fallback: for example, 50% of traffic to Claude, 50% to GPT, and Gemini if both fail.

A custom Python module, which the author demonstrates, is structured as follows: a chain of models, a transport function with retries, strict parsing of the response against a Pydantic schema, extraction of JSON from text that has a preamble, "repair" of a broken response at zero temperature, and, for critical flows, a cheap judge model. The module tracks metrics: how many responses the primary model produced, how many times the fallback triggered, how many contract violations occurred, and how many times the judge rejected a response.

What breaks in the backup model

The main risks are format and tools. One model supports JSON Schema, another only "json mode" without guarantees, and a third supports neither. Tool call arguments are formulated differently, and quality drops unevenly: on file rewriting a model may be on par, but weaker in a narrow domain. Parameters such as temperature also affect models differently.

Therefore you need structural guarantees, not persuasion through the prompt. Validate responses against a schema, test the backup on your own real data, and log which model answered.

Conclusion

A backup gateway is a compatibility agreement, and the second key is only its transport layer. Users don't care what your uptime is if the response arrives broken. And remember: the fallback service is itself another production component with its own deployment, alerts, and the risk of becoming a single point of failure. The source text breaks off at this point, but the overall message is clear: start with the cheap layers and move to switching providers as rarely as possible.

Story

Key Questions Answered

Why a second key doesn't solve the problem?

The standard answer is to set up a second API key and switch to it when the first returns a 500. You will save availability, but not the meaning of the response. Another model, even one "of the same class," writes differently, handles JSON schemas and tool calls differently, and interprets your prompts differently. The application will keep running, but with someone else's text that nobody has checked against expectations set by the primary model. The author of the Habr analysis distinguishes two concepts.

What are the key details on The cascade and error types?

Fault tolerance is built as a pyramid, where each next level is more expensive and riskier: retry with exponential backoff and random jitter, which only fixes short-lived failures; a different deployment of the same model, for example GPT on Azure as primary and OpenAI directly as backup, where the response format stays the same; a different model from the same provider, say from Claude Sonnet to Haiku, which is cheaper but behaves differently; an entirely different provider, which gives maximum…

What are the key details on Tools: LiteLLM, OpenRouter, Portkey, and your own code?

LiteLLM is the most flexible option if you want to keep the logic in-house. It works both as a library and as a proxy with a single OpenAI-compatible endpoint. It supports general fallbacks, separate context_window_fallbacks and content_policy_fallbacks, cooldown (after N failures a deployment drops out of rotation for a while), on-the-fly fallback management via API, and budget checks before switching to an expensive model. The cost is maintenance: versions, updates, the issue tracker.

ZK
Zhemal Khamidun — Head of AI at Alpina Digital · MIPT (academic supervisor of the Tech Entrepreneurship department). Building AI products since 2019. Hamidun News is a pet project that grew into a production aggregator with 6,000+ readers.
✦ Unified AI Workspace · Nomad

Test Frontier LLMs & Autonomous Agents in One Workspace

Run Claude Opus 5.5, GPT-6, Gemini 3.1, and DeepSeek side-by-side in Nomad AI (nomadnet.ai) — unified model routing, deep research, and multimodal workflows under one subscription.

Try Nomad AI →Launch Nomad Agent
Jemal Hamidun

Editor-in-chief · Cite this analysis

Jemal Hamidun

Head of AI at Alpina Digital · Academic Supervisor of the Tech Entrepreneurship Department at MIPT

Head of AI & CPO of AlpinaGPT at Alpina Digital, Academic Lead of Tech Entrepreneurship at MIPT. Founder of Hamidun News and Vibe Academy.

Ready-to-paste citation for journalists, blogs and Telegram channels

Source: Hamidun News — Five Hours of LLM API Downtime a Month: How to Build a Fallback Without Losing Meaning https://news.hamidun.com/en/news/18547/five-hours-of-llm-api-downtime-a-month-how-to-build-a-fallba

What do you think?
Loading comments…