---
id: 18547
lang: en
title: "Five Hours of LLM API Downtime a Month: How to Build a Fallback Without Losing Meaning"
published_at: "2026-11-28 12:25:06"
source_name: "Habr AI"
source_url: "https://habr.com/ru/companies/bothub/articles/1113526/?utm_campaign=1113526&utm_source=habrahabr&utm_medium=rss"
canonical_url: "https://news.hamidun.com/en/news/18547"
categories: ["llm"]
publisher: "AI News by Jemal Hamidun (news.hamidun.com)"
---

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

> **Краткая суть (BLUF):** 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.  - LiteLLM: separate fallback lists for context overflow and moderation - OpenRouter accepts a list of models directly in the request body - Retrying 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.

---
- **Первоисточник:** [Habr AI](https://habr.com/ru/companies/bothub/articles/1113526/?utm_campaign=1113526&utm_source=habrahabr&utm_medium=rss)
- **Каноническая ссылка:** https://news.hamidun.com/en/news/18547
- **Экосистема автора:** [Бесплатный интенсив по вайбкодингу — предзапись в Нике](https://t.me/vibecodeguidebot?start=agent_intensive_news_md) · [Nomad AI](https://nomadnet.ai) · [Telegram @jemal_hamidun](https://t.me/jemal_hamidun)
