DEV Community

Cover image for LLM Provider Fallback: Survive a Suspended Model
jamilxt
jamilxt

Posted on Originally published at jamilxt.com

LLM Provider Fallback: Survive a Suspended Model

On December 1, a startup that builds an AI support agent for online stores published a post about the worst week to lose a model. In the middle of the post-Black Friday rush, every request to their main model came back with one line:

model: "claude-opus-5-5" is suspended for this organization
Enter fullscreen mode Exit fullscreen mode

Their customers never noticed. Every call had an LLM provider fallback on a different model family, so traffic moved to OpenAI's GPT models without anyone getting paged. This article turns that story into a working setup: a small Python router that sorts errors and fails over, plus a checklist for making your eval traffic easy to explain if a trust and safety team ever asks about it.

One note before we start. Only the startup's side of this story is public. No public response from Anthropic was found at the time of writing, so everything below about the suspension comes from the post itself.

What happened to the support startup?

According to the post, the sequence went like this:

  • A week before the suspension, their inference provider's Trust & Safety team emailed them. Some traffic "appeared inconsistent with Anthropic's Usage Policy". The post says this meant it looked like distillation (using a model's answers to train another model). They had 24 hours to respond.
  • The flagged traffic was their test suite. Before each change ships, they run a fixed set of scripted support conversations several times each. They run them on both the old and the new version, and a model grades the answers.
  • They replied within a couple of hours, explained the traffic, and asked how to label eval traffic so it would stop getting flagged. They offered a dedicated key, request metadata, code and logs.
  • They got no reply. About a week later, the model was gone.

The post shows one ordinary day of spend from the month before: about $1,280, $984 of it on Claude Opus 5.5. They send all Claude traffic through zero-data-retention providers. In the Hacker News thread (over 500 points), the author added a detail that matters for anyone planning a fallback: they used two model routers and six inference providers between them, and Opus 5.5 was suspended on all of them at the same time.

That last point is the main lesson for engineers, and we will come back to it.

Why can an eval suite look like distillation?

Anthropic has written about this directly. In its February 2026 post on distillation attacks, it describes campaigns by three labs that generated over 16 million exchanges through about 24,000 fraudulent accounts. It also explains what gives these campaigns away: "Massive volume concentrated in a few areas, highly repetitive structures, and content that maps directly onto what is most valuable for training an AI model."

Now think about a regression suite. It sends the same prompts again and again, in bursts, on one narrow task. The same February post also lists "rubric-based grading tasks that made Claude function as a reward model" among the targets of one lab's campaign. The startup's suite used a version of that pattern too: a model grades the agent's answers (often called LLM-as-a-judge).

None of this proves why this startup was flagged. It only shows that honest eval traffic and distillation traffic can share a shape. Anthropic's October 2026 follow-up says its new classifier has "a false positive rate of less than 0.1%" and admits it can "misidentify or block benign requests". At high request volume, a small rate still means some real customers get caught.

What do Anthropic's terms say about suspension?

Two documents matter here.

The Usage Policy (effective Nov 12, 2026) lists "Use outputs to train an AI model (e.g., 'model scraping' or 'model distillation') without prior authorization from Anthropic" as a prohibited use. It also says that if Anthropic suspects a violation, it "may warn you or throttle, limit, suspend, or terminate your access".

The Commercial Terms (section I.3) allow a "Service Suspension" when Anthropic "reasonably believes or determines" that a customer is breaking its policies or use restrictions. Anthropic "will use reasonable efforts to provide written notice", and it takes no liability for losses caused by the suspension.

In plain terms: a suspension can come first, and the explanation later or never. Your architecture has to assume that.

There is also a privacy detail. The startup chose zero data retention (ZDR) routes because their support chats contain personal data. Anthropic's data retention page covers ZDR and HIPAA arrangements. It says that even with those in place, flagged data can be kept: "if a chat or session is flagged, Anthropic may retain inputs and outputs for up to 2 years." If you promised customers zero retention, read that section before you repeat the promise.

Inference provider vs model vendor: which fallback actually helps?

There are three kinds of fallback, and they protect you from different failures.

  • Same model, different inference provider. Claude through a second router or cloud. This helps when one provider has an outage. It did not help here: the startup had six providers and lost Opus 5.5 on all of them at once.
  • Same vendor, different model. Anthropic's own server-side fallback (beta) retries a request on another Claude model when the first one refuses. It is built for classifier refusals, which arrive as a normal HTTP 200 with stop_reason: "refusal". It does not help when your organization has lost access. The startup did pin parts of their system to an older Claude model that still worked, but you cannot plan around that.
  • Different model vendor. Claude to GPT, Gemini, or an open-weights model you host. This is the only kind that survives a vendor deciding to stop serving you.

A commenter in the thread put it in one line: do not depend on a single model provider, "not inference provider, different thing".

Routers can do part of this for you. OpenRouter's models parameter takes a list of model IDs in priority order and tries the next one when "any error" happens, including rate limits and downtime. You are billed for the model that answered. That is a good default, but you still want your own code to know which failures are permanent, so you can alert on them.

How to build an LLM provider fallback in Python

The router below uses the official anthropic and openai Python SDKs. It does three things:

  1. Sorts each error into permanent (401, 402, 403: key, billing or access problems), transient (408, 409, 429, 5xx, connection errors) or request (other 4xx).
  2. Closes a route after a failure: one hour for permanent errors, 30 seconds for transient ones. A permanent error is logged at ERROR level so it pages someone.
  3. Treats a refusal (stop_reason == "refusal") as a reason to try the next route.
import logging
import os
import time
from dataclasses import dataclass
from typing import Callable

import anthropic
import openai

log = logging.getLogger("llm_router")

# How long a route stays closed after each kind of failure.
# "request" errors do not close the route: the next provider gets the
# same request in its own format and may accept it.
BENCH_SECONDS = {"permanent": 3600, "transient": 30, "request": 0}


def classify(err: Exception) -> str:
    """Sort a provider error into permanent, transient, or request."""
    if isinstance(err, (anthropic.APIConnectionError, openai.APIConnectionError)):
        return "transient"  # also covers timeouts
    status = getattr(err, "status_code", None)
    if status in (401, 402, 403):
        return "permanent"  # bad key, billing, or access removed
    if status in (408, 409, 429) or (status is not None and status >= 500):
        return "transient"  # rate limit, overload, server trouble
    return "request"  # 400, 404, 413: this provider rejected this request


class Refused(Exception):
    """The model answered with stop_reason 'refusal'."""


@dataclass
class Route:
    name: str
    call: Callable[[str, list], str]
    closed_until: float = 0.0


def anthropic_route(model: str, client: anthropic.Anthropic) -> Route:
    def call(system: str, messages: list) -> str:
        resp = client.messages.create(
            model=model, max_tokens=1024, system=system, messages=messages
        )
        if resp.stop_reason == "refusal":
            raise Refused(model)
        return "".join(b.text for b in resp.content if b.type == "text")

    return Route(f"anthropic:{model}", call)


def openai_route(model: str, client: openai.OpenAI) -> Route:
    def call(system: str, messages: list) -> str:
        resp = client.chat.completions.create(
            model=model,
            messages=[{"role": "system", "content": system}, *messages],
        )
        return resp.choices[0].message.content or ""

    return Route(f"openai:{model}", call)


class Router:
    def __init__(self, routes: list[Route]):
        self.routes = routes

    def complete(self, system: str, messages: list) -> tuple[str, str]:
        last_err = None
        for route in self.routes:
            if route.closed_until > time.time():
                continue
            try:
                return route.name, route.call(system, messages)
            except Refused as err:
                log.warning("%s refused, trying next route", route.name)
                last_err = err
            except (anthropic.APIError, openai.APIError) as err:
                kind = classify(err)
                route.closed_until = time.time() + BENCH_SECONDS[kind]
                level = logging.ERROR if kind == "permanent" else logging.WARNING
                log.log(level, "%s %s failure: %s", route.name, kind, err)
                last_err = err
        raise RuntimeError("all routes failed") from last_err


def build_router() -> Router:
    # max_retries=1 keeps the SDK's own retries short, so failover stays fast.
    claude = anthropic.Anthropic(max_retries=1, timeout=60)
    gpt = openai.OpenAI(max_retries=1, timeout=60)
    return Router([
        anthropic_route(os.environ["PRIMARY_MODEL"], claude),
        openai_route(os.environ["FALLBACK_MODEL"], gpt),
    ])
Enter fullscreen mode Exit fullscreen mode

Set PRIMARY_MODEL to your Claude model ID and FALLBACK_MODEL to the GPT model you have actually tested your prompts on. The keys come from the usual ANTHROPIC_API_KEY and OPENAI_API_KEY variables.

A few design choices need explaining.

Why the status code, not the message text? The startup's post does not say which HTTP status the suspension used, and with a router in the middle it could be rewritten. Message text is also unstable. Anthropic's error docs say you "shouldn't match" the 429 spend-cap message in code, and the refusal docs say the same about refusal explanations. Status codes are stable. A 403 permission_error means "your API key does not have permission to use the specified resource", which is the closest documented match for lost access.

Why one SDK retry? The Anthropic SDK already retries connection errors, timeouts, 408, 409, 429 and 5xx, and it follows the x-should-retry and retry-after headers. It does not retry a 403. Keeping max_retries low means a struggling primary costs your user seconds, not minutes, before the fallback answers.

Why does a closed route reopen? After an hour, the router sends one request to the primary again. If access came back, traffic returns on its own. If not, that one request fails and the route closes for another hour.

Why catch only API errors? A bug in your own code (a KeyError, a bad format string) should crash loudly. If you catch every Exception, your bugs look like provider failures and get quietly routed around.

Testing the failover without real keys

You can check the control flow with a local stub server that speaks both APIs. Both SDKs read their base URL from the environment, so you can point them at the stub:

export ANTHROPIC_BASE_URL=http://127.0.0.1:8766
export OPENAI_BASE_URL=http://127.0.0.1:8766/v1
Enter fullscreen mode Exit fullscreen mode

Then make the stub return different failures. In a local run, the stub returned a 403 permission_error with the exact suspension line, then a 529, then a refusal. The output, trimmed:

ERROR anthropic:claude-opus-5-5 permanent failure: Error code: 403 - {... 'is suspended for this organization' ...}
[suspended]  first=openai:gpt-stub second=openai:gpt-stub hits={"anthropic": 1, "openai": 2} closed=[3600, 0]
[overloaded] first=openai:gpt-stub second=openai:gpt-stub hits={"anthropic": 1, "openai": 2} closed=[30, 0]
[refusal]    first=openai:gpt-stub second=openai:gpt-stub hits={"anthropic": 2, "openai": 2} closed=[0, 0]
Enter fullscreen mode Exit fullscreen mode

The suspended route took one failed request, then stayed closed for the hour while GPT answered. (first and second show which route answered two calls in a row; hits counts the requests each stub endpoint received.) The overloaded route (529) closed for 30 seconds. The stub also sent x-should-retry: false, so the SDK did not retry the 529; against the real API, the SDK may retry once first, depending on that header. A refusal does not close the route, because the next request may be fine. This tests the routing logic only. It says nothing about how good the fallback model's answers are, which is the next problem.

How do you know the fallback still works?

A fallback you never test is a guess. Another commenter in the thread named the real risk: "Prompts tuned for one model often get quietly worse on another, and that's what bites during an outage."

So run a small part of your eval set against the fallback model on a schedule, for example weekly, and track its score next to the primary's. When the gap grows, fix the prompts for the fallback before you need it. This also spreads your eval traffic across two vendors instead of sending all of it to one.

How do you make eval traffic easy to explain?

None of these steps guarantees you will never be flagged. They make your traffic easier to explain, and they cut the volume that looks repetitive.

  • Give evals their own workspace and key. Anthropic workspaces separate projects or environments, each with its own keys and limits. Every response carries an anthropic-workspace-id header. A suspension "for this organization" can still hit every workspace, so this is about a clean answer when someone asks "what is this traffic?", not about protection.
  • Set metadata.user_id. The Messages API accepts an opaque ID per request, and the docs say "Anthropic may use this id to help detect abuse." Use a stable hash for your eval runner and per-customer hashes in production, never names or emails.
  • Do not ask the grader to write out its reasoning. Anthropic's refusal docs list a reasoning_extraction category. Common triggers include a reasoning, thinking or trace field in JSON output, or a <thinking> scratchpad. A judge prompt that asks for a reasoning field before the score matches that description. Ask for a short explanation or the evidence behind the score instead. Refusals in this category are billed before any output, and this category has no recommended fallback model.
  • Cut repeat volume. Cache answers for prompts that did not change between runs, and run the full suite on release branches instead of every commit.
  • Keep a one-page description ready. Write down what the suite does, which keys it uses, how many requests a run sends, and when it runs. Keep request IDs (request-id header) for a sample of runs. The startup answered within hours. That is much easier when this page already exists.

FAQ

Does Anthropic's server-side fallback protect against a suspension?
No. It retries refused requests on another Claude model inside one API call. A suspended organization is an access problem, not a refusal, so you need a model from another vendor.

Is using several inference providers for the same model enough?
Not for this failure. The startup lost Opus 5.5 on six providers at once. The author reads that as a decision at Anthropic, not at any one provider.

Which errors should trigger a failover?
All of them, but with different follow-ups. In the code above, 401, 402 and 403 close the route for 1 hour and log an error that should page someone. 429, 529 and other 5xx close it for 30 seconds. A refusal moves to the next route without closing anything.

Does ZDR mean my flagged requests are deleted?
Not always. Anthropic says flagged sessions may be kept for up to 2 years even under ZDR or HIPAA arrangements.

If your product went down today because one model vendor stopped answering, how long would it take you to switch, and have you ever tried it?

Top comments (0)