How a single provider fails
Model fallback only makes sense once you have seen how a lone provider lets a chatbot down. None of these are exotic. With a bring-your-own-key setup the provider’s limits become your limits, so each one can silence your chat.
| Failure | What you see | Usual cause | Lasts |
|---|---|---|---|
| Rate limit | HTTP 429 | Too many requests or tokens per minute for your tier | Seconds to minutes |
| Overload or server error | HTTP 5xx, “overloaded” | The provider is busy or a node is failing | Seconds to minutes |
| Outage | Timeouts, connection errors, many 5xx at once | A provider incident | Minutes to hours |
| Exhausted credit or quota | 402, or 429 with “quota” or “insufficient balance” | Prepaid balance empty or a spend limit reached | Until you add credit |
| Invalid or revoked key | 401 or 403 | Key deleted, rotated or mistyped | Until you fix it |
| Retired or unavailable model | 404, “model not found” | The provider retired the model name or your account lacks access | Permanent for that name |
| Timeout | No reply within the step’s time | A slow model, long reasoning or a very large prompt | Varies |
| Empty or malformed reply | A response with nothing usable in it | A rare model or gateway glitch | Usually one-off |
Notice the mix. Some failures clear themselves, some need you to act, and one of them, a retired model, can arrive on a quiet Tuesday with no outage at all. A chatbot that handles only the first group will still break. Our troubleshooting guide covers fixing each one.
What a fallback chain is
A chain is an ordered list of steps. Each step names a key, a model and a few parameters. For every visitor message the system tries step one, and if that step fails in a way another model could fix, it moves to step two, and so on down the list. If a step answers, the visitor never learns that a switch happened.
Two ideas make the difference between a chain that helps and one that merely exists. First, the failures have to be classified: switching on every error is wasteful, and switching on none is useless. Second, the switch has to preserve the conversation: if step two starts from a blank page, a visitor halfway through a booking sees the agent forget everything.
Which errors should fall through, and which should not
The rule is simple: fall through when a different step could plausibly succeed, and stop when it could not.
| Error | Falls through? | Reason |
|---|---|---|
| Network error or timeout | Yes | Another provider may be reachable. |
| 429 rate limit | Yes, after retries | Another key or provider has its own limit. |
| 5xx or overloaded | Yes, after retries | A different provider is probably healthy. |
| Invalid, expired or unauthorized key | Yes | The key is also marked as failing so you see it in the dashboard. |
| Retired model, or a prompt too large for that model | Yes | It is a fault of the step, not of the request. |
| Empty or malformed reply | Yes | A second attempt elsewhere is a quick fix. |
| Content-policy refusal | No | Another model would usually refuse the same request, and quietly routing around a refusal is the wrong default. |
| Bad request | No | The request itself is wrong, so another provider would not fix it. Fixing it is your job. |
The two “no” rows deserve a sentence each. A refusal is information: a model declined for a reason, and sending the same text to a more permissive model until one complies defeats the point of a safety layer. A bad request is a bug: if every provider returns the same complaint, falling through just multiplies the failed calls and delays the visitor. Some errors look like bad requests but are really limits of one model, such as a prompt longer than that model’s context window. Those count as a problem with the step, and the chain moves on.
How SiteTrellis runs a fallback chain
Every agent has a model chain in the builder. The behaviour below is what you get without writing any code; the details are in the AI keys overview and Build your agent.
- Steps. Each step is a key, a model and parameters: temperature, maximum reply length, a timeout (3 to 55 seconds, default 30) and retries (0 to 3, default 1).
- Retry before falling through. A temporary error is retried on the same step after a short backoff. Timeouts are not retried, because the step has already spent its time.
- A failing step is skipped for a short while. If a step keeps failing, later visitors do not wait on a provider that is known to be down. If every step looks unhealthy, the chain still tries them in order rather than give up without trying.
- Context is rebuilt for each step. A switch in the middle of a conversation keeps working, including the history of tool calls such as a captured lead or a lookup.
- One time budget. The whole reply has an overall time budget of well under a minute, so several slow steps cannot add up to a visitor waiting forever.
- A friendly failure message. If every step fails, the visitor sees the message you wrote for the agent instead of a raw error.
- Plan limits. The chain can have 2 steps on Free, 3 on Starter and 5 on Pro.
The conversation trace in the dashboard records each attempt with its model, status and error, which is how you tell afterwards that a fallback happened.
Design patterns that work
| Pattern | Benefit | Watch out for |
|---|---|---|
| Small, fast model first, stronger model second | Low cost and quick replies for most chats, a safety net with more capability | The second model answers differently and costs more per reply |
| Same lab, different model | Similar style, same account and billing | A lab-wide outage or key problem takes out both steps |
| Different lab, same size | Protects against a provider outage and a provider-wide rate limit | Two accounts to fund and two privacy agreements to read |
| OpenRouter as the second route | One key that reaches models from several labs | It is a separate account with its own balance, and a failing key or empty balance there helps no one |
Small model first, then a stronger one
Most website chats are short questions that a small model answers well, so putting one first keeps cost and latency down. The stronger model then covers the rare case where the first one is unavailable. Do not read this as “escalate hard questions”: the chain switches on errors, not on difficulty.
Cross-provider fallback
The strongest protection against a provider incident is a step with a different provider, because the first step’s rate limits, balance and outages are then irrelevant to the second. The price is operational: another account, another spend limit and another set of data terms. Setting one up is covered in the guides for Anthropic, OpenAI, Gemini, DeepSeek and OpenRouter. How to choose an LLM for website chat helps pick the pair.
Make every step tool-capable
If your agent captures leads or calls custom tools, every step must use a model that supports tools. A fallback that cannot call the tool leaves the chat answering but unable to do its job.
What fallback costs
A fallback chain costs nothing while it is idle: you pay a provider only for the requests it receives. The cost appears when a step answers. Two examples from our catalog, as estimates for 1,000 conversations under the default assumptions (6 visitor messages per conversation, 1,500 tokens of prompt and knowledge sent every turn, and 180-token replies): about $1.79 on Claude Haiku 5.5 and about $35.88 on Claude Sonnet 5.5. Your provider’s invoice is authoritative.
So if a stronger model sits in step two, the conversations that fall through cost the stronger model’s rate, and an extended incident on the first provider moves your whole bill to the second. A request that a provider rejects outright is generally not charged, but a request that times out after generation started might be, so read each provider’s billing rules. A retry on the same step can also repeat a request, which is another reason to keep the retry count low. The practical advice: set a spend limit at every provider in the chain, not only the first, and use the cost calculator to see what a second-step model would cost if it had to carry all your traffic.
How to test a fallback chain
Do not wait for a real outage to find out whether your chain works. You can rehearse the failure on purpose, in the playground, which does not count against your plan’s conversations.
Add a deliberately broken key
In AI providers, add a key entry with a made-up value. SiteTrellis saves it, tests it and marks it failing. Alternatively use a real key with a tiny spend limit at the provider to provoke a quota or 429 error.
Put it in step one
In the agent builder, make the broken key the first step and your real key the second.
Ask a question in the playground
The reply should still arrive, a little slower. Open the conversation trace to see the failed attempt on step one and the answer from step two.
Test the tools mid-conversation
Start a conversation with the good step first, then break it and carry on. Check that tool calls and earlier context survive the switch.
Break every step
Make all steps invalid and confirm that the friendly failure message appears, and that you are happy with its wording.
Restore and republish
Put the real key back in step one, test it, and only then publish. Remove the broken key entry so it does not confuse you later.
Because a playground chat uses your real key, rehearsals cost a few cents at most. They are worth repeating after you change models, since providers retire model names.
What fallback does not do
Fallback improves resilience. It does not guarantee uptime. If every step in the chain fails, or the whole reply runs out of its time budget, the visitor sees the failure message.
- A different model answers differently. Tone, length and the way it follows your instructions can change. Test your key questions on every step, not only the first.
- It cannot fix a shared cause. Two steps that use the same key, the same exhausted balance or the same retired model fail together.
- Failed attempts take time. A timeout before the switch makes that one reply slower, so use sensible per-step timeouts and a fast first step.
- It does not refresh credit or rotate keys. Watch for keys flagged as failing and top up balances, ideally before a visitor notices.
For the underlying model behind a chat, a quick refresher is what BYOK means for AI chatbots, and our BYOK page shows where fallback fits in the whole setup.