Book a 30-min callBook a call

LLM routing and fallbacks: sending each request to the right model, and surviving outages

How LLM routing works: rules, classifiers, cascades, learned and semantic routers, plus fallbacks, retries, 429 handling, router evals and tracing.

A request arrow entering a diamond router that splits to a small and a large circle, with dashed arrows escalating from the small to the large and falling back from the large to a backup box.
Written by
BYD Tech
Published
Topic
Deep dives
Reading time
16 min read

Questions people ask

Is an LLM router the same as an LLM gateway?

Not quite. A gateway is infrastructure in front of providers: one API, keys, rate limiting, logging and often retries and fallbacks. A router is the decision of which model should answer a given request. Many gateways include simple routing rules, and many routers run inside a gateway, but the hard part of routing, deciding by difficulty and checking that quality holds, needs your own data and evals.

Should a fallback model get exactly the same prompt?

Start from the same internal request, but expect to adapt it. Tool and schema formats differ between providers, and an instruction tuned on one model can behave differently on another. Keep a per-provider adapter and run your eval set against every model in the chain, not only the primary.

How do I stop retries from making an outage worse?

Cap the attempts and the total time, back off exponentially with jitter, honor retry-after, and never retry quota, billing or authentication errors. Use a circuit breaker so a failing provider is skipped for a cooldown period, and make sure only one layer, your code or the SDK, is retrying.

Can I trust a model's own confidence score for routing?

Only as a weak hint. A number the model writes about itself is not a calibrated probability. Prefer signals you can check against labeled data: token log-probabilities on short answers, a small trained scorer, or verifiers such as schema validation and tests, and set the escalation threshold from an evaluation set.

Do cascades make responses slower?

For the requests that escalate, yes: they wait for the small model's answer and then the large one's. For the requests the small model handles, they are usually faster. The balance depends on the escalation rate, so measure it; if many requests escalate, route up front instead.

Building something like this?