TL;DR — Updated 1 November 2026: the original October chain is out of date, and the calendar now forces the rebuild. OpenAI shut down its legacy snapshots on 23 October 2026, Claude Sonnet 4.5 retires on 30 November 2026, and OpenAI's new gateway-approval rule takes effect on 20 November 2026. The rebuilt chain below — Claude Sonnet 5.5, then Haiku 5.5, then DeepSeek V4.1 Flash 1017 on one tokens.bd key — cuts a heavy session from $3.00 to $0.15 when it falls back, a 20× saving, and adds the circuit breaker the original post was missing.
On 3 September 2026, three of the biggest AI providers stumbled inside the same few hours. OpenAI detected elevated error rates across ChatGPT and Codex around 10:58 UTC and needed about 24 minutes to apply mitigations; Anthropic's Claude Sonnet 5 had elevated errors the day before, resolved in roughly 25 minutes; Google's Gemini took around 2 hours to fully recover. That June, Claude's API and Claude Code went through a major incident on the 2nd, with status history recording more disruptions through the 16th — ten incidents in twelve days. OpenAI's own status history shows separate incidents on July 22, 23, 24, and 25.
None of this means any provider is uniquely unreliable. It means model APIs are infrastructure, and every infrastructure dependency eventually fails. Independent monitoring puts major AI providers at 99.9% availability across 2026 — which sounds airtight until you multiply: 0.1% of 8,760 hours is about 8.8 hours of downtime a year. The question is never "will my provider go down?" but "what does my app do when it does?"
What changed since October 2026 — and why does the old chain need rebuilding?#
Three dated events since this post was first checked on 12 October 2026 change what a safe chain looks like. First, on 23 October 2026 OpenAI shut down its legacy API snapshots — gpt-3.5-turbo-0125, gpt-4-0613, gpt-4-1106-preview, gpt-4-turbo-2024-04-09, gpt-4.1-nano-2025-04-14, gpt-4o-2024-05-13, gpt-image-1, o1-2024-12-17, o1-pro-2025-03-19, o3-mini-2025-01-31 and o4-mini-2025-04-16, plus their fine-tunes — and any chain still naming one of those IDs now fails outright; it does not get routed to a replacement. Second, Anthropic deprecated Claude Sonnet 4.5 on 30 September 2026 with a tentative retirement date of 30 November 2026 on Anthropic-operated platforms, naming claude-sonnet-5-5 as the replacement; the original post's claude-sonnet-4-5 rung has 29 days left. Third, OpenAI's updated Usage Policies, announced 21 October 2026 and effective 20 November 2026, require services that provide direct access to its models — model routers and AI gateways are named — to get OpenAI's review and approval before offering that access. Ordinary apps that use OpenAI models for their own features are explicitly outside that rule, but if your fallback plan routes through a gateway, ask that provider about its approval status in writing before 20 November and keep a second route. This post makes no claim about any specific provider's approval status.
The original post's own example needs the same treatment: its second rung, claude-3-5-haiku, was already retired on 19 February 2026, when Anthropic retired claude-3-5-haiku-20241022 — so that rung never worked at all, and the rebuild below replaces it with Haiku 5.5. Two more dates belong on the same calendar. The bare gpt-4o alias was not shut down on 23 October — only the gpt-4o-2024-05-13 snapshot was — but the gpt-4o snapshots (2024-08-06, 2024-11-20), gpt-4o-mini and the gpt-4.1 snapshots follow on 14 January 2027, with gpt-6-luna as OpenAI's named replacement, and the first-generation gpt-5 snapshots, o3 and o3-pro go on 11 December 2026. A chain is only as current as its model IDs, so audit them on a schedule, not when something breaks.

What are the three layers of a fallback chain?#
A fallback chain is an ordered list of attempts, not a single retry. Layer 1 is SDK retries: the same request, same provider, retried on transient errors. Layer 2 is model-tier failover: the provider is reachable but your model is not — rate-limited, capacity-constrained or degraded — so you switch to a cheaper model on the same provider with the same key and billing. Layer 3 is cross-provider failover: the whole provider is down, so you send the request to a different provider's model entirely. Most production outages that hurt are layers 2 and 3, and most apps only have layer 1.
| Layer | What it covers | What it costs |
|---|---|---|
| SDK retries | Seconds-long blips: timeouts, brief 429s, connection resets | Nothing extra — same request, same price |
| Model-tier failover | One model rate-limited or degraded; context-window overflows | Cheaper backup model, usually 5–20× less per call |
| Cross-provider failover | Full provider outage or billing lockout | A second provider account and key — or one gateway key covering many providers |
How much does a fallback actually cost?#
A fallback is usually cheaper than the primary it replaces, and that is the point: the rung you fall back to should be the cheapest model that can still do the job. The table below prices a heavy coding session — 1M input tokens and 100K output tokens — at tokens.bd's list prices, checked 1 November 2026, converted at approximately 124 BDT per USD (mid-market rate, 1 November 2026). Every figure is recomputed from those two inputs; the chart below the table plots the same numbers.
| Model (tokens.bd, checked 1 November 2026) | Input / 1M | Output / 1M | Heavy session (1M in + 100K out) | In BDT (approx.) |
|---|---|---|---|---|
| Claude Sonnet 5.5 | $2.00 | $10.00 | $3.00 | ~372 BDT |
| Claude Haiku 5.5 | $0.10 | $0.50 | $0.15 | ~19 BDT |
| GPT-6 Luna | $0.15 | $0.60 | $0.21 | ~26 BDT |
| DeepSeek V4.1 Flash 1017 | $0.30 | $0.80 | $0.38 | ~47 BDT |
| GLM-5.3 Flash | $0.17 | $0.55 | $0.23 | ~28 BDT |
| Qwen 3.8 Flash | $0.18 | $0.52 | $0.23 | ~29 BDT |
| Gemini 3.8 Flash | $1.65 | $8.25 | $2.48 | ~307 BDT |
| Kimi K3.1 Pro | $2.10 | $10.50 | $3.15 | ~391 BDT |

Read the table as a chain, not a ranking. A Sonnet 5.5 session that falls back to Haiku 5.5 costs $0.15 instead of $3.00 — 20 times less — and the fallback still answers. The expensive mistake is the opposite order: three blind retries of a failing Sonnet 5.5 session cost $9.00 (about 1,116 BDT) and buy nothing if the model itself is the problem, while one Sonnet attempt plus one Haiku fallback costs $3.15 in total. On a plan, a Weekly 5X $10 credit covers about 66 Haiku heavy sessions but only about 3 Sonnet ones; a Monthly Max $50 credit covers about 333 against about 16. That is why the cheap rung exists — not to save money on good days, but to keep serving on bad days without burning the month's budget in an afternoon.
How do SDK retries work — and where do they stop helping?#
The official OpenAI Python SDK already retries connection errors, 408 timeouts, 409 conflicts, 429 rate limits, and 5xx errors — 2 times by default, with short exponential backoff. You can tune it per client or per request, and you should, because the default timeout is 10 minutes per attempt: one stuck request can hold a worker for roughly half an hour across its three attempts. Set both numbers on purpose for user-facing traffic.
from openai import OpenAI
client = OpenAI(
api_key="sk-...",
timeout=20.0,
max_retries=3,
)
response = client.chat.completions.create(
model="gpt-6-luna",
messages=[{"role": "user", "content": "Extract the invoice total."}],
)Two gotchas. First, a retry that keeps hammering a failing endpoint can become its own outage amplifier — keep the retry budget small and move to failover instead of increasing it past 3. Second, not every 429 is worth retrying: a quota-exhausted 429 never recovers by waiting, so route on that distinction instead of retrying blindly. And retries never help with the October lesson: a retired model ID returns a deterministic error, so retrying it three times just fails three times, slower.
How do you build a hand-rolled fallback loop?#
When retries are exhausted, walk the chain. This pattern works with any OpenAI-compatible client, including tokens.bd — you only change the base_url and the key, and the model IDs below are tokens.bd's current IDs, checked 1 November 2026. The chain is Sonnet 5.5 first, Haiku 5.5 as the same-provider cheap rung, then DeepSeek V4.1 Flash 1017 as the cross-provider rung.
import openai, time
def chat_with_fallback(client, chain, messages, timeout=20.0):
"""chain: list of model IDs tried in order; returns (model, response)."""
last_error = None
for model in chain:
try:
response = client.with_options(
max_retries=0,
timeout=timeout,
).chat.completions.create(model=model, messages=messages)
return model, response
except (openai.RateLimitError, openai.InternalServerError,
openai.APITimeoutError, openai.APIConnectionError) as e:
last_error = e
time.sleep(1)
except openai.APIStatusError:
raise
raise last_error
model, resp = chat_with_fallback(
client,
chain=["anthropic/claude-sonnet-5-5",
"claude-haiku-5-5",
"deepseek-ai/deepseek-v4.1-flash-1017"],
messages=[{"role": "user", "content": "Summarize this diff."}],
)
print(f"Served by {model}:", resp.choices[0].message.content[:200])The except openai.APIStatusError: raise line matters: 400/401/403/404 errors are deterministic — no fallback will fix a bad key, a malformed request, or a retired model ID, so fail loudly instead of burning a second provider's quota on a request that can never succeed. Log which model actually served each request; when you review an incident later, "served by" is the column that tells you whether the chain did its job. Set a per-rung timeout, not just a per-request one: three rungs at 20 seconds each plus backoff is roughly a minute of worst-case latency, a budget you chose rather than a surprise.
When should you use OpenRouter's model array instead?#
If you route through OpenRouter, the chain moves server-side. Send a models array instead of a single model — OpenRouter tries the primary, then falls through the array in order on downtime, rate limits, moderation refusals, context-length validation errors, or other failures, and the response's model field tells you which one answered. The fallback list is only consulted when the primary actually fails — you are not paying for standby, and you are billed for the model that answered. And OpenRouter's provider routing has an allow_fallbacks flag (on by default) that controls whether a request may move between providers behind the same model slug; set it to false when you need a request to stay on one provider for compliance reasons, and copy current model IDs from OpenRouter's own model list rather than from any article, because they change. The trade-off against the hand-rolled loop is control: server-side fallbacks are less code, but you cannot add your own circuit breaker, per-rung timeout, or "served by" log line.
When should you self-host the chain with LiteLLM?#
If you prefer to own the chain, LiteLLM's Router maps logical model names to deployments and defines fallbacks per name. Fallbacks are tried in order, and the first succeeding model's response is returned. The example below uses current model families; LiteLLM's own model strings are provider-native, so check them against LiteLLM's model list before deploying.
from litellm import Router
model_list = [
{"model_name": "primary",
"litellm_params": {"model": "openai/gpt-6-luna", "api_key": "sk-openai"}},
{"model_name": "backup",
"litellm_params": {"model": "anthropic/claude-haiku-5-5",
"api_key": "sk-ant"}},
]
router = Router(
model_list=model_list,
fallbacks=[{"primary": ["backup"]}],
num_retries=2,
cooldown_time=60,
)
response = router.completion(
model="primary",
messages=[{"role": "user", "content": "Hello"}],
)LiteLLM also supports context_window_fallbacks (used when a request exceeds the primary's context window) and content_policy_fallbacks (used on moderation refusals) — failover conditions you can't express with a plain retry loop. Its router settings add the two knobs the hand-rolled loop needs most: allowed_fails, the failure count within the cooldown window after which a deployment is cooled down, and cooldown_time in seconds, how long it stays out of rotation. Own the chain when you need those knobs or compliance control over keys; use a gateway when you would rather not operate the router at all.
How do circuit breakers and cooldowns stop a bad rung burning money?#
A fallback loop without a breaker will happily try a dead rung on every request, paying the timeout on each one until the provider recovers. A circuit breaker fixes that with three states. Closed is normal: requests flow and failures are counted. Open is the tripped state: after N consecutive failures within a window, the rung is skipped entirely for a cooldown period — no requests, no timeouts, no bill. Half-open is the probe: after the cooldown, one request is allowed through to test recovery; success closes the breaker, failure re-opens it. LiteLLM implements this with allowed_fails and cooldown_time; a hand-rolled loop needs the same idea in about twenty lines — a failure counter per rung, a retry-after timestamp, and a skip rule checked before each attempt. The shape is not optional: a chain that retries a dead rung forever is not resilient, it is a retry storm with extra steps.

One more guardrail belongs with the breaker: a spend cap on the fallback path. A runaway fallback loop that keeps succeeding expensively on the backup tier is worse than an outage, because it looks healthy while it drains the budget. On tokens.bd, a tripped cap surfaces as a 403 monthly_spend_cap_exceeded instead of a surprise bill, with alerts at 50%, 75%, 90% and 100% warning that a failover is running hot before the cap trips.
How do you test a fallback chain before an outage tests it for you?#
A fallback you have never triggered is a fallback you do not have, so break the primary on purpose. Set SDK retries to 0, point rung 1 at an invalid key or a retired model ID, and confirm rung 2 answers. Then break rung 2 as well and confirm rung 3 answers. Check the logs for the "served by" line, measure total latency against your per-rung budget, and confirm the bill shows the fallback model's price, not the primary's. Repeat the test after every model-ID change — the October retirements are exactly the kind of change that silently breaks an untested chain — and keep a dated checklist: primary broken, secondary broken, all rungs broken (does the error surface cleanly?), cooldown observed (is the dead rung skipped?), cap behavior (does the alert fire before the cap?).
What does tokens.bd's built-in failover cover — and what stays yours?#
tokens.bd ships with automatic failover built in: requests are failed over to another upstream on 429, 5xx, and connection errors — rung 2 and part of rung 3 happen without any client code. That covers the provider-side failures in this post's evidence section; the client-side chain above still matters for the cases the gateway can't see, like a quota-exhausted key or a context-window overflow. Per-key spend caps cut off a runaway fallback loop with a 403 monthly_spend_cap_exceeded instead of a surprise bill, and usage alerts at 50%, 75%, 90%, and 100% tell you a failover is running hot before the cap trips. If you run the fallback loop above against tokens.bd, the only change is the client setup:
from openai import OpenAI
client = OpenAI(
base_url="https://tokens.bd/v1",
api_key="tk-...",
)
# chain: anthropic/claude-sonnet-5-5 -> claude-haiku-5-5 -> deepseek-ai/deepseek-v4.1-flash-1017The full model catalog, the API docs, pricing, and the gateway comparison cover setup, pricing in USD and BDT, and how tokens.bd's failover compares with OpenRouter's routing. For what a gateway actually is and when one replaces hand-rolled chains, see What Is an AI Gateway?. For the opposite problem — choosing the cheapest model that can handle a request, rather than surviving its failure — see LLM Model Routing. The October refresh of Claude Code With Other Models prices the same models as gateway sessions.
FAQ#
Why did my old fallback chain break in October 2026? Most likely a retired model ID. OpenAI shut down its legacy snapshots on 23 October 2026 — pinned IDs like gpt-4-0613, gpt-4o-2024-05-13 and o1-2024-12-17 stopped answering that day, and no fallback can fix a request naming a dead ID. Search your code for every retired ID, move each hit to OpenAI's listed replacement, and re-run your break-the-primary test. A Sonnet 4.5 chain still works today but retires on 30 November 2026 — rebuild that rung now, not on the 30th.
What does OpenAI's 20 November 2026 gateway rule change for my fallbacks? If you fall back through a gateway or router that provides direct access to OpenAI models, that provider needs OpenAI's review and approval before offering the access, under Usage Policies effective 20 November 2026. Ask your provider for written confirmation covering your exact service and route, and keep a second route so one approval decision cannot strand your pipeline. If you only use OpenAI models to power your own app's features, the rule does not apply to you on that basis. This post makes no claim about any specific provider's approval status.
What errors should trigger a failover? Timeouts, connection errors, 429 rate limits, and 5xx server errors. Don't fail over on 400, 401, 403, or 404 — those are deterministic and will fail on every provider. Quota-exhausted 429s also never recover; fail fast and surface them. Retired-model errors are deterministic too: falling over to another model is fine, retrying the dead ID is not.
Isn't the OpenAI SDK's built-in retry enough? It covers seconds-long blips: 2 retries with exponential backoff on connection errors, 408, 409, 429, and 5xx. It can't switch models or providers, so it does nothing when your model is capacity-constrained, retired, or the whole provider is down. That's what rungs 2 and 3 are for — and why the SDK timeout deserves its own setting, since the default 10 minutes per attempt can hold a worker for half an hour.
Should the fallback be a cheaper model? Usually, yes. A cheaper backup on the same provider is the best value rung: it absorbs rate-limit and capacity events at a fraction of the cost — Haiku 5.5 at $0.15 per heavy session against Sonnet 5.5's $3.00, checked 1 November 2026. Reserve the cross-provider rung for full outages and billing lockouts, and put a spend cap behind the whole chain so a fallback that keeps succeeding expensively cannot drain the budget silently.
How do I test my fallback chain? Break the primary on purpose: set SDK retries to 0, use an invalid key or a retired model ID as rung 1, and confirm rung 2 answers. Then break rung 2 and confirm rung 3 answers. Check the logs for the "served by" line, measure latency against your per-rung budget, confirm the bill shows the fallback model's price, and re-run the test after every model-ID change.
Updated 1 November 2026. Originally checked 12 October 2026. Model IDs, prices and policy dates change; the provider docs are the authority for current behavior, and the model catalog for models on tokens.bd.
Sources: OpenAI API deprecations page · OpenAI — Broad access through consistent standards (21 October 2026) · Anthropic model deprecations · Crypto Briefing — 3 Sept 2026 outages · SoftwareReviews — overlapping AI outages · fewshot-works/academy — June 2026 Claude outage analysis · openai-python README — retries · OpenRouter — How model routing works · LiteLLM proxy config settings — router_settings · tokens.bd models · tokens.bd vs OpenRouter — automatic failover · tokens.bd docs · USD/BDT mid-market rate, 1 November 2026



