One evening, right after I deployed a routine batch job, the API started answering "this model is currently unavailable." I retried the same call about ten times and succeeded only in fattening the logs.
It took me a while to see that a retry means "try the same conditions again." If the thing being refused is the model ID itself, waiting changes nothing. What you need is a design that switches the request, not one that waits.
This feels closer to home in November 2026 than it did when I first wrote about it. On the Claude API, claude-sonnet-4-5-20250929 is scheduled to retire on November 30, and the official deprecations page says the undated claude-sonnet-4-5 retires with it. My earlier fallback table had exactly that ID sitting in the "backup" column.
Below is how I separate this error from 529 and 429, how I ask the Models API about a model's lifecycle and capabilities at startup, and how I switch models per request. I've left in the places where my earlier version was simply wrong, because those taught me the most.
The short version
Three things, up front:
- Switch models only when the model itself can't be accepted. Congestion (529) and your own usage (429) belong to the SDK's retries.
- Don't paper over a 403 permission error with a fallback. Tell a human.
- A backup model may want
thinkingwritten differently. Swap only the model ID and you can trade a 404 for a 400.
The third one is the easiest to miss. I hit it once: the fallback kicked in, and the backup immediately failed with a different error.
What this error is actually telling you
A 529 Overloaded or a 429 Rate Limit is about congestion or your own usage. Waiting usually works, so the SDK's automatic retries are the right tool. The official TypeScript SDK retries connection errors, 429s and 5xx responses twice by default with exponential backoff, and you can change that with the client's maxRetries option (checked against the official errors page, November 2026).
This error is different: "the model ID you named can't be accepted on this route." Sometimes it clears; for a retired model, it never will. If you handle both families with one net, you either push load onto your fallback during a congested spell or keep retrying a permanent refusal.
Here are the entries from the official error list that matter for this article:
| Status | type | Meaning (paraphrasing the docs) | What I do |
|---|---|---|---|
| 400 | invalid_request_error | Something is wrong with the request's format or content | Fix the request. Fall back only if the message points at the model |
| 403 | permission_error | The key lacks permission for the resource | No fallback. Notify a human |
| 404 | not_found_error | The requested resource was not found | Fall back |
| 429 | rate_limit_error | A rate limit or spend cap was hit | No fallback. Let the SDK retry |
| 529 | overloaded_error | The API is temporarily overloaded | No fallback. Let the SDK retry |
The error text varies by route (Anthropic direct or a cloud provider) and over time, and the docs themselves recommend branching on the SDK's typed exceptions rather than matching strings. The deprecations page only says that requests to retired models "fail"; it doesn't name a status code, and I haven't verified every route myself. Please log the response you actually get once, in your own setup.
Telling the causes apart
In what I've seen, refusals fall into roughly six situations. I haven't measured frequencies, so I won't rank them.
| Symptom | Likely cause | How to check | Fix |
|---|---|---|---|
| An ID that worked yesterday now returns 404 | The model retired | Look up its lifecycle in the Models API; compare with the deprecations page | Move to the recommended replacement; let the fallback cover the gap |
| Only a brand-new ID fails | Not yet on this route or region, or a typo | Query the ID through the Models API with the same key | Keep the previous generation as primary for now |
| Fails only on Bedrock or Vertex AI | Providers set their own model lists and dates | Check that provider's model table; Anthropic's dates cover Anthropic-operated routes | Keep a candidate list per route |
| 400 right after switching to the backup | The backup rejects the thinking setting | Read the error and capabilities.thinking.types from the Models API | Build thinking per model |
| 403 | The key or workspace lacks access | Check org and workspace settings in the Console | Switching won't fix it. Notify and fix by hand |
| 429 or 529 keeps coming back | Usage or congestion | Is there a retry-after header? A spend-cap 429 has none | Retry and throttle. Keep the model |
Row five may be the one that matters most. Never hide a permission refusal behind a fallback. If the switch "works," you lose sight of a configuration mismatch you really needed to notice.
Ask the Models API at startup
I used to keep model capabilities and lifetimes in a hand-written table. It was only a matter of time before that went stale, and it did. These days I call the Models API (GET /v1/models/{model_id}) once when the process starts and cache the result.
According to the reference, the response carries lifecycle (active, deprecated or retired), retires_at (the scheduled retirement time), and, under capabilities.thinking.types, whether the model accepts adaptive, enabled, disabled and so on.
import Anthropic from "@anthropic-ai/sdk";
// Only the parts of the Models API response this article uses
interface ModelProbe {
id: string;
lifecycle: "active" | "deprecated" | "retired";
retiresAt: string | null;
thinkingAdaptive: boolean;
thinkingEnabled: boolean;
}
async function probeModel(client: Anthropic, id: string): Promise<ModelProbe | null> {
try {
// Older SDK versions may not type the newer fields, so read them after the call
const info = (await client.models.retrieve(id)) as unknown as Record<string, any>;
const types = info.capabilities?.thinking?.types ?? {};
return {
id: info.id,
lifecycle: info.lifecycle ?? "active",
retiresAt: info.retires_at ?? null,
thinkingAdaptive: Boolean(types.adaptive?.supported),
thinkingEnabled: Boolean(types.enabled?.supported),
};
} catch (err) {
if (err instanceof Anthropic.NotFoundError) return null; // no such ID
throw err;
}
}
async function probeChain(client: Anthropic, ids: string[]): Promise<Map<string, ModelProbe>> {
const usable = new Map<string, ModelProbe>();
for (const id of ids) {
const p = await probeModel(client, id);
if (!p) {
console.error(`[models] ${id} not found — remove it from the chain`);
continue;
}
if (p.lifecycle === "retired") {
console.error(`[models] ${id} is retired`);
continue;
}
if (p.lifecycle === "deprecated") {
console.warn(`[models] ${id} is deprecated, retires_at=${p.retiresAt}`);
}
usable.set(id, p);
}
return usable;
}This tells you, before any real traffic, whether every ID in your table exists and whether one is about to retire. The day the deprecated warning first appears is the day to start migrating. The docs also note that retires_at can be revised until retirement happens, and a past date on a deprecated model means retirement is overdue, not done — lifecycle is the actual signal. So I don't decide on the date alone.
Keep a fallback table
Next comes a table of "preferred model" and "backup" per use case. I used only IDs listed as Active on the official deprecations page as of November 2026.
type ModelTier = "frontier" | "balanced" | "fast";
interface ModelFallbackChain {
primary: string;
fallbacks: string[];
}
// Before editing, confirm each ID against the official models and deprecations pages
const FALLBACK_CHAINS: Record<ModelTier, ModelFallbackChain> = {
frontier: { primary: "claude-opus-5-5", fallbacks: ["claude-opus-5", "claude-opus-4-8"] },
balanced: { primary: "claude-sonnet-5-5", fallbacks: ["claude-sonnet-5", "claude-sonnet-4-6"] },
fast: { primary: "claude-haiku-5-5", fallbacks: ["claude-sonnet-5"] },
};My previous version had claude-sonnet-4-5 as the balanced backup. After November 30, that backup stops being one. An even older version listed IDs like claude-haiku-4 that I had never confirmed existed. The backup column turned out to be the place that needs the most care.
Audit the backup column as often as the primary. Rows that only run when something breaks are exactly the rows nobody reads, so they rot first.
Tell the rejections apart by exception class
I branch on the type of exception the SDK throws, not on substrings of the message. Wording changes; the meaning of a status code tends not to.
type Verdict = "fallback" | "alert" | "rethrow";
// 404: model not found -> switch
// 403: no permission -> don't switch, tell a human
// 429 / 529 / anything else: leave it to SDK retries, no fallback
function classify(err: unknown): Verdict {
if (err instanceof Anthropic.NotFoundError) return "fallback";
if (err instanceof Anthropic.PermissionDeniedError) return "alert";
if (err instanceof Anthropic.BadRequestError) {
// 400 also covers bad parameters; switch only when the message points at the model
const msg = (err.message ?? "").toLowerCase();
if (msg.includes("unavailable") || msg.includes("not available")) return "fallback";
}
return "rethrow";
}
async function invokeWithFallback(
client: Anthropic,
tier: ModelTier,
usable: Map<string, ModelProbe>,
buildRequest: (probe: ModelProbe) => Anthropic.Messages.MessageCreateParamsNonStreaming
): Promise<{ message: Anthropic.Messages.Message; depth: number }> {
const chain = FALLBACK_CHAINS[tier];
const candidates = [chain.primary, ...chain.fallbacks].filter((id) => usable.has(id));
let lastError: unknown = new Error(`no usable model for tier ${tier}`);
for (const [depth, modelId] of candidates.entries()) {
try {
const message = await client.messages.create(buildRequest(usable.get(modelId)!));
return { message, depth };
} catch (err) {
const verdict = classify(err);
if (verdict === "fallback") {
console.warn(`model ${modelId} rejected, trying next`);
lastError = err;
continue;
}
if (verdict === "alert") {
await notifyOwner(`permission denied for ${modelId}`); // wire this to your own channel
}
throw err; // anything we don't switch on goes back up, unswallowed
}
}
throw lastError;
}IDs that failed the startup probe never enter the candidate list. I keep 429 and 529 outside the fallback on purpose: moving the same load onto a backup during congestion doesn't, in my view, make anything better. Retries are the SDK's job via maxRetries; switching is reserved for "this model can't be accepted."
The backup may want thinking written differently
The trap I stepped in hardest is the thinking setting. The official thinking page has a per-model table of how each thinking value is handled. As of November 2026 it boils down to this:
| Model generation | No thinking field | type: "adaptive" | type: "enabled" + budget_tokens |
|---|---|---|---|
| Opus 5.5 / Sonnet 5.5 / Haiku 5.5 / Opus 5 / Sonnet 5 | Adaptive thinking | Accepted | 400 |
| Opus 4.8 / Opus 4.7 | Thinking off | Accepted | 400 |
| Opus 4.6 / Sonnet 4.6 | Thinking off | Accepted | Accepted (deprecated) |
| Opus 4.5 / Sonnet 4.5 / Haiku 4.5 | Thinking off | 400 | Accepted |
So a budget_tokens request that falls over to a 5-series model gets a 400, and an adaptive request that falls back to the 4.5 generation gets a 400 too. My old code guessed capabilities from model names in a hand-written table, and on top of that passed budget_tokens: 16384 with max_tokens: 4096. The budget has to be smaller than max_tokens, so that request failed on the very first call, fallback or not. I "knew" it worked only because I had tested the path with thinking off.
Now I build the request from the ModelProbe captured at startup:
function buildRequestFor(
probe: ModelProbe,
prompt: string
): Anthropic.Messages.MessageCreateParamsNonStreaming {
const base = {
model: probe.id,
max_tokens: 16000,
messages: [{ role: "user" as const, content: prompt }],
};
if (probe.thinkingAdaptive) {
// 5-series thinks adaptively even without this; 4.6–4.8 only think when it's set
return { ...base, thinking: { type: "adaptive" } } as Anthropic.Messages.MessageCreateParamsNonStreaming;
}
if (probe.thinkingEnabled) {
// Manual budget for the 4.5 generation; keep budget_tokens below max_tokens
return { ...base, thinking: { type: "enabled", budget_tokens: 8000 } };
}
return base; // models without thinking get nothing extra
}The as cast is there because some SDK versions don't type adaptive yet. If yours does, drop it. The rule hasn't changed from before: when unsure, remove features and make sure an answer comes back.
Claude Code's fallback versus a hand-rolled one
Claude Code has its own "fallback model chain" that moves to the next model when the primary is overloaded or unavailable. Per the official model configuration page, it never switches on authentication, billing, rate-limit or request-size errors; the switch lasts for the current turn only, so the next message tries the primary first again; and chains are capped at three models after removing duplicates.
| Aspect | Claude Code fallback model chain | The hand-rolled version here |
|---|---|---|
| Switches on | Overloaded, unavailable, other non-retryable server errors | 404, and 400s whose message points at the model |
| Never switches on | Auth, billing, rate limit, size, transport | 403, 429, 529, everything else |
| How long the switch lasts | One turn | One request |
| Per-model feature handling | Handled by Claude Code | Yours to write (thinking and more) |
The two disagree on overload. For an interactive tool, getting some answer from another model is usually the kinder outcome. For the batch jobs I write, a change in output quality is itself the risk, so I'd rather wait. Interactive tools should keep answering; routine jobs should stay consistent. Which side you pick depends on what the job is for.
Common misunderstandings
"An undated ID won't retire." It will. The deprecations page states that the Sonnet 4.5 retirement includes the undated claude-sonnet-4-5. Writing the alias doesn't quietly move you to a successor.
"Bedrock and Vertex AI stop on the same day." The dates on the deprecations page apply to Anthropic-operated routes such as the Claude API; Amazon Bedrock and Google-managed Google Cloud set their own schedules. A different route can mean a different date.
"budget_tokens works on every model." On Opus 4.7 and later and on the 5 series it's a 400. On 4.6 it's accepted but deprecated. The more generations your chain mixes, the more likely you are to hit this.
Record that a switch happened
A fallback gets harder to notice the better it works. If the primary stays down and the backup quietly carries the load, everything still looks like success on screen.
interface ModelInvocationLog {
timestamp: string;
intendedModel: string;
actualModel: string; // the response's model field
fallbackDepth: number; // 0 = primary succeeded
taskType: string;
outcome: "success" | "all_failed";
}I aggregate this once a week and look at the share of calls with fallbackDepth of 1 or more. The threshold worth acting on depends on how critical the job is, so I'd suggest watching a few weeks of real numbers before choosing one. I didn't pick a number up front either; I started by collecting. The docs also say the Console's Usage page can export a CSV broken down by API key and model, which is a handy way to see which key is still calling an ID that's about to retire.
Reproduce this path in development
Errors that only show up in production tend to get tested last. Passing a non-existent ID such as claude-opus-99-test as model should return a not-found error. Log the response you actually get once and use it as test data for classify, so CI can confirm each stage of the chain moves on correctly.
You can reproduce the thinking mismatch the same way. Sending type: "enabled" with budget_tokens to a 5-series model should return a 400; keep that response as a fixture for buildRequestFor.
Realising "I never tested this path" at the moment a model drops in production is a stomach-turning experience. Since that night I also test the case where every stage fails and the code reaches throw lastError.
Where people get stuck next
Once a fallback is in place, the next wall is usually the inventory: which IDs are written where. If an old ID survives in an environment variable or a saved setting, not just in code constants, the fallback will drop to the same backup every time.
Whether an undated alias escapes the retirement is covered in the undated claude-sonnet-4-5 and the November 30 deadline. Finding retiring models in the usage CSV is in inventorying usage CSVs before the Sonnet 4.5 retirement. For checking IDs against the catalog before a bulk replace, see catalog lookup before bulk-replacing model IDs, and for the wider picture of staying available across models, multi-model fallback for high availability may help.
One thing to do today
At startup, query every ID in your fallback table through the Models API once, and log any whose lifecycle isn't active. With November 30 coming up, that alone shows whether a retiring ID is hiding in your backup column.
That was my first step too, and it's how I ended up rewriting the backup column. The classify function that separates 404 from 403 can come after; I think that order is enough.