LLM fallback routing

LLM fallback routing: failover across models and providers

When a model errors, times out or stops answering, the AI Stupid Level Smart Router sends the same request to the next model in a chain it built before the first attempt: up to 5 fallbacks, your own order first, then automatic picks that prefer another provider. A model that keeps failing is skipped for 60 seconds, and the response says which model answered.

Get a free router key

1,000 routed requests a month free · your own provider keys · no card

5
fallback models at most on every routed request.
60s
skip for a model after 5 provider-side failures in a row.
120s
without a first byte, and a stream moves to the next model.

01

How does the Smart Router build the fallback chain?

Every routed request carries its fallbacks from the start: up to 5, taken in this order from the models your keys, exclusions and limits allow.

1. The rest of your traffic split
With auto-split, each request draws its primary model by weight, and the other models of the split follow, heaviest first.
2. Your own fallback order
Up to 10 models you list in Preferences, tried in your order. A model with no key, an excluded one, or one that is failing right now is left out.
3. Automatic picks
Up to 2 more: the next models in your mode’s own ranking, preferring providers that are not in the chain yet.
Models passed over
By default, a model with an active drift alert on the suite your mode relies on goes behind the unflagged ones. It is not removed: if every candidate is flagged, the highest-ranked of them is still used. How drift is detected.

02

What makes a request fall back?

An attempt that ends without an answer moves the request to the next model in the chain. Attempts run one after another, and the first answer is returned.

Provider-side failures
A 5xx, an overloaded or at-capacity answer, a timeout or an empty response. These also count toward that model’s circuit breaker.
A rate limit on your key
A 429 from your provider account. The next model takes the request, and that key rests on that model for 15 seconds, doubling with each 429 in a row up to 120 seconds. A success ends the rest.
A key or credit problem
A provider that refuses your saved key, or an account out of credit there.
A model already known to be failing
A model whose circuit is open, or whose provider our health checks report as down, is skipped without being called.
A refusal is not a failure
When a model declines a request, the reply comes back with message.refusal. It is not sent to other providers and not counted against your plan.

03

How does the circuit breaker work?

Fallbacks protect one request. The circuit breaker protects the ones after it, so they do not each pay a failed attempt on a failing model.

Opens after five failures
Five provider-side failures in a row on one model open its circuit. For the next 60 seconds requests skip that model and go to the next one in their chain.
Probes before it returns
After the 60 seconds one request at a time is let through as a probe. Two successes in a row close the circuit, and a failed probe opens it for another 60 seconds.
Counts what the provider did
A circuit counts 5xx answers, overload, timeouts and empty responses. A request the provider rejected as malformed, a refused key, an account out of credit and a rate limit on your own key do not open it.
A provider-wide check beside it
Independently, a short completion goes to every provider every 10 minutes from our own account, and a provider that check reports as down is passed over until it answers again. Each provider’s history is on the status page.

04

Does a streamed response fall back?

Until the first byte
A streamed attempt that fails before sending anything is skipped like any other, and the next model streams instead. A provider that has sent nothing after 120 seconds is treated the same way.
After the first byte
Text that has been sent cannot be taken back. A failure after that ends the stream with an error event, code stream_interrupted.

05

How do I see a fallback happen?

The sandbox can simulate one. The request below runs through the real routing, treats the first model as failed and answers from the second with a mock reply. No provider is called.

cURLsandbox · simulated fallback
curl -i https://aistupidlevel.info/v1/chat/completions \
  -H "Authorization: Bearer aism_your_key_here" \
  -H "Content-Type: application/json" \
  -H "X-ASL-Sandbox: true" \
  -H "X-ASL-Sandbox-Simulate: fallback" \
  -d '{"model": "auto-coding", "messages": [{"role": "user", "content": "Hello!"}]}'

# Response headers
# X-AISM-Sandbox: true
# X-AISM-Model: <the second model in the chain>
# X-AISM-Reasoning: Sandbox: Fallback activated: <first model> failed -> routed to <second model>. ...
X-AISM-Model
The model that answered: the fallback, when one did. Its provider is in X-AISM-Provider.
X-AISM-Reasoning
On a fallback it reads “Fallback activated” and names the model that failed and the one the request was routed to. The sandbox puts “Sandbox:” in front.

POST /v1/route/preview returns the chain before anything is sent: the primary model, the fallbacks in order and fallback_enabled. Both are in the router documentation.

06

What does the router return when every model fails?

What went wrong decides the status, so a client can tell an outage from a setting it has to fix. Each of these lists the models tried in tried_models.

502 model_unavailable
Every model tried failed on the provider side. The message gives the last provider’s error.
429 provider_rate_limited
Your provider key is rate-limited on every model tried. Retry-After says when to try again.
429 provider_quota_exceeded
Your provider account refused for credit or quota. It carries x-should-retry: false, so an OpenAI SDK does not retry it in a loop.
400 provider_key_rejected
The provider refused your saved key. Replace it under Provider keys.
400 provider_rejected_request
The provider rejected the request itself. Its own words are in the message.

07

How do I set up fallbacks?

On by default
Try other models automatically is on for a new account. Turn it off under When a model fails in Preferences, and a request fails with that model’s own error.
Your fallback order
Add up to 10 models and move them into order. They are tried before the automatic picks.
A second provider key
With keys for two or more providers, a fallback can answer from a different provider than the primary. BYOK LLM router.

Fallbacks work behind any tool that sends a routing mode: Cline, OpenCode, LangChain and n8n, with the rest on the integrations hub. What an AI router is sets fallbacks beside the other things a router does. Related guides:

08

Questions about fallback routing

What is LLM fallback routing?

Fallback routing sends a request to a second model when the first one fails, so an error at one model or provider need not become an error in your application. The AI Stupid Level Smart Router builds the chain before the first attempt: up to 5 fallbacks on every routed request, your own fallback order first, then up to 2 automatic picks that prefer another provider. The response headers name the model that answered.

What is the difference between fallback and failover?

They describe the same move at two scales. Fallback is the rule for one request: this model failed, try the next. Failover is what that adds up to when a provider is down: traffic moves to another provider and comes back when the first one answers again. In the Smart Router the chain does the first and the circuit breaker the second.

How many fallback models does a request get?

At most 5. With no fallback order of your own, a request has its primary model and up to 2 automatic fallbacks. Your own order can hold up to 10 models, and the chain takes them first.

Do fallbacks apply when I name a model?

Fallbacks belong to routed requests: auto and the auto-* modes. A request that names a model id is sent to that model and no other, which is what naming a model is for. To get a chain, send a mode.

Does a failed attempt count against my plan?

No. Plans count successful requests. A request that fails on every model is not counted, and one that a fallback answers is counted once. Plans and prices.

Keep answering when a provider does not

Free includes 1,000 routed requests a month on every provider and every mode, with your own provider keys and no card.

Get a free router key

1,000 routed requests a month free · your own provider keys · no card

See the boards it routes on

Coding, Reasoning, Tool use and Combined, over 24 hours, 7 days and 30 days.

Already have an account? Log in