Vibe Engines
YouTube

Vibe Engines is free, interactive AI engineering & system design — runs in your browser. Pick a learning path

Handbooks  /  Model Routing
Handbook~15 min readProductionworked math + runnable code
The Model Routing Handbook

Send the easy ones
somewhere cheap.

Most of what an LLM app handles is easy — a greeting, a lookup, a short rephrase — and paying flagship prices for all of it is like flying first class to the corner shop. Model routing fixes that: a cheap model takes the easy majority, the expensive one is reserved for the genuinely hard. Done right it slashes the bill with barely a dent in quality. But there's a catch buried in the arithmetic — a cascade makes you pay the cheap model on everything, so one number, the escalation rate, decides whether you save or lose. This handbook makes that number precise.

01

Not every job needs the flagship

Production LLM traffic is lopsided: a small fraction of requests are genuinely hard (multi-step reasoning, tricky code, ambiguous instructions), and the rest are easy. Yet the default architecture sends all of it to one big, expensive model. Model routing replaces that flat policy with a tiered one — match each request to the cheapest model that can actually handle it — echoing the same idea that makes mixture-of-experts efficient: don't activate the whole giant when a small part will do.

Because price gaps between model tiers are large (a small model can be 10–100× cheaper than a flagship), moving even a modest share of traffic to a cheaper tier is a big win. And since the easy majority is exactly where cheap models are already good enough, routing usually cuts cost sharply while leaving quality almost untouched. The whole discipline reduces to one question: how do you decide which model gets each request, and what does that decision cost?

The one-sentence version

Send each request to the cheapest model that can handle it — but because a cascade pays the cheap model on everything, the escalation rate decides whether you actually save.

02

The cascade

The most common routing design is a cheap-smart cascade. Every request goes to the cheap model first. Then you check whether the cheap answer is trustworthy — via a confidence score, a quick self-check, or a small verifier — and only when it's unsure do you escalate the request to the expensive model. Confident cheap answers are returned directly; the rest fall through to the flagship.

A request through a cascade
Cheap modelRuns on every request first — cheap, fast, good enough for the easy majority.
ConfidenceCheck the cheap answer: high confidence → return it.
EscalateLow confidence → send to the expensive model.
CostYou pay cheap always, plus big on the escalated fraction.

The cascade is appealing because it decides with the cheap answer in hand: the cheap model's answer is never returned for a request it flagged as hard, so a difficult query is caught whenever the confidence check notices it struggling — unlike a router, which must guess before seeing any answer. The catch is the case the check misses: a cheap model that is confidently wrong slips through (see Pitfalls). The price of that reliability is the cheap model's cost on every request — including the ones that end up escalating anyway, where you've paid twice. That double-pay on escalated requests is exactly what the cost math has to weigh.

03

Escalation is the lever

Here's the counterintuitive part. If your cheap model escalates everything, the cascade costs more than just using the big model — you've paid the cheap model's price on top of the flagship's, for nothing. The cascade only saves money when the cheap model actually resolves a large share of requests, keeping the escalation rate low.

So the single number that determines success is the escalation rate — the fraction of requests that fall through to the expensive model. Everything you do to improve routing (a better confidence signal, a stronger cheap model, a smarter threshold) is really an effort to push that rate down. And how low it needs to go depends on the price gap: a much cheaper cheap-model tolerates a high escalation rate; a barely-cheaper one demands a very low one. The next section turns this into an exact break-even.

04

The break-even math

Let the cheap and big model costs per request be ccheap and cbig, and let r be the escalation rate. The cascade pays the cheap model on all requests and the big model on the escalated fraction:

E[costcascade]  =  ccheap + r·cbig     vs     costalways-big = cbig

The ccheap term is paid on every request, escalated or not — that is the cascade's overhead.

Set them equal and solve for the escalation rate at which the cascade breaks even:

ccheap + r*·cbig = cbig  ⟹  r* = 1 − ccheap/cbig

If the cheap model is 1/20 the price (ccheap=1, cbig=20), break-even is r*=0.95 — you can escalate up to 95% of traffic and still win. If it's 1/100 the price, r*=0.99. The bigger the price gap, the more escalation you can afford. Stay below r* and the cascade saves money; go above and it loses. The runnable version below computes the cascade cost, the break-even, and where a cascade wins or loses.

RUN IT YOURSELF

Cost a cascade

A cascade's economics are one equation. You pay the cheap model on every request plus the big model on the escalated fraction, so the cost is c_cheap + rate × c_big versus c_big for always-big. Escalate everything and the cascade costs more than the flagship (the cheap call is wasted); the cascade wins only when the escalation rate is below break-even, which equals 1 − c_cheap/c_big. A bigger price gap raises the break-even, so a much cheaper first tier tolerates far more escalation. Change the escalation rate or the prices and watch where the cascade wins.

CPython · WebAssembly
05

Routers vs cascades

Cascades aren't the only routing design. The main alternatives trade overhead against risk:

DesignHow it works
CascadeCheap model first, escalate on low confidence — reliable, but pays cheap on everything.
Predictive routerA small router classifies difficulty up front and sends each request directly to the right tier — no wasted cheap call, but risks mis-routing a hard one.
Confidence thresholdTune the escalation threshold to trade cost against quality — the knob on any cascade.
Task-based routingRoute by request type (classification → cheap, deep reasoning → flagship) with simple rules.
Semantic routingEmbed the query and route by similarity to known easy/hard clusters or to a specialist model.

Predictive routers avoid the cascade's double-pay by not running the cheap model on requests destined for the flagship — but they can send a hard request to the cheap model and get a bad answer, since they decide before seeing any output. Cascades never make that mistake but pay more. In practice many systems combine them: a fast router for obvious cases, a cascade with a verifier for the rest. Either way, this is cost engineering applied to model selection — measure your escalation rate and price gap, and the right design follows.

06

Pitfalls

The dangerous failure is a bad confidence signal. A cascade is only as good as its ability to know when the cheap model is wrong — and cheap models are often confidently wrong, which is the worst case: high confidence, wrong answer, no escalation. If your escalation trigger doesn't correlate with actual correctness, you'll ship cheap mistakes while thinking you're safe. Validate the signal against real accuracy, not the model's self-reported certainty.

Two more. Latency: a cascade adds the cheap model's time to every escalated request, so tail latency can rise even as cost falls — sometimes a predictive router is better for latency-sensitive paths. And cost per successful outcome is the real metric: a cheap answer that fails and triggers a retry, a complaint, or human review can cost more end-to-end than routing straight to the flagship. As with all AI cost work, measure the full-funnel cost of an outcome, not the sticker price of a call — then the escalation rate and price gap tell you exactly where the cascade pays.

Worth knowing

The scariest escalation-rate error is a cheap model that's confidently wrong: it clears the confidence threshold, never escalates, and ships a bad answer. Calibrate the escalation trigger against measured correctness, not the model's own confidence.

By the numbers

Worked example: pricing a cascade for one month of traffic

A support assistant gets 100,000 requests a month. The flagship costs $0.02 a request and the cheap model $0.001, the page’s 1:20 gap, so break-even is r* = 0.95. Assume the flagship’s answers are always right, and that a wrong answer that slips through costs $0.25 to clean up (a retry, a ticket, a human look). All of these numbers are illustrative. Trace it row by row.

StepPolicyArithmeticModel spendWith clean-up
1Always flagship100,000 × $0.02$2,000$2,000
2Cascade, cheap pass on everything100,000 × $0.001$100 (paid at every rate)—
3Cascade, 20% escalate$100 + 20,000 × $0.02$500—
4Cascade, 95% escalate$100 + 95,000 × $0.02$2,000 (break-even)—
520% escalate, 3% of the 80,000 cheap answers confidently wrong$500 + 2,400 × $0.25$500$1,100
6Stricter threshold: 30% escalate, 1% of 70,000 wrong$100 + 30,000 × $0.02 + 700 × $0.25$700$875
7Predictive router, same 20% sent straight to the flagship80,000 × $0.001 + 20,000 × $0.02$480plus whatever it mis-routes

Step 5 is the one dashboards hide. On model spend alone the cascade looks 75% cheaper. Count the confidently wrong answers and it is 45% cheaper. Step 6 is the counterintuitive fix: escalating more raised model spend by $200 but cut clean-up by $425, so the cost per correct outcome fell. Latency moves the other way. Say the cheap model answers in 0.4 s and the flagship in 2.0 s. At 20% escalation the mean drops from 2.0 s to 0.8 s, but escalated requests take 2.4 s (both calls), and they are 20% of traffic. So p95 gets worse than the always-flagship 2.0 s. Step 7 saves the $20 of wasted cheap calls on hard requests, but only if the router is right before it sees any answer. None of steps 5 and 6 can be read off logs: the 3% and the 1% come from labelling a random sample of cheap-resolved answers by hand, a few hundred a week, and re-running it whenever the threshold, the prompt or either model changes.

In the wild

Where this shows up in production and interviews

  • The research lineage

    FrugalGPT (Stanford, 2023) framed the LLM cascade: try cheaper models first and stop when a learned scorer trusts the answer. RouteLLM (LMSYS, 2024) trained predictive routers on human preference data from Chatbot Arena. They are the two designs on this page, cascade and router, written up with evaluations.

  • Gateways and fallbacks

    LLM gateways sit between an app and its providers. They usually carry routing rules (by task, tenant or prompt size) and fallback chains to another model when one errors or times out. A fallback chain is a cascade triggered by failure, not by low confidence, and it has the same double-pay on every request that falls through.

  • Task-split pipelines

    Many agents already route without calling it that: a small model classifies intent, extracts fields or summarises tool output, and the flagship only plans and writes the final answer. The escalation rate here is fixed by design, so cost is predictable. The risk moves to the hand-off between the two models.

  • The interview version

    In “cut our LLM bill” or “design a support bot”, write c_cheap + r·c_big and solve for r* out loud. Then say how you will measure r and the confidently-wrong rate (a labelled sample, re-checked weekly), and name the latency cost to the escalated tail. That is the part interviewers listen for.

Self-check

Check yourself

Your cheap model costs 1/5 of the flagship and escalates 85% of requests. Does the cascade save money?

No. Break-even is r* = 1 − 1/5 = 0.8. At 85% the cost is 0.2 + 0.85 = 1.05× the flagship. A small price gap tolerates very little escalation. Lower r first, or drop the cascade and use a predictive router, which skips the cheap call on requests it already knows are hard.

An audit finds 3% of the cheap model’s high-confidence answers are wrong. What should you change first, the threshold or the price tier?

The threshold, and then measure cost per correct outcome, not model spend. As in step 6, a stricter threshold raises r and spend but can cut clean-up cost by more. A cheaper tier would lower spend while likely raising the wrong-answer rate. The trigger has to be calibrated against measured correctness, not the model’s own confidence.

A voice assistant has a hard p95 latency budget, and 20% of its requests are hard. Cascade or predictive router?

Router. In a cascade the 20% that escalate pay cheap latency plus flagship latency, and 20% is more than the 5% that p95 ignores, so the tail gets slower than always-flagship. A router sends hard requests straight to the flagship with one call. You accept some mis-routing risk to keep the tail flat.

Prices fall and your cheap model goes from 1/20 to 1/100 of the flagship. What happens to how much escalation you can afford?

It rises from r* = 0.95 to 0.99. The fixed overhead, c_cheap on every request, shrinks relative to the flagship price, so even a cascade that escalates most traffic still saves. Quality risk is unchanged: the confidently-wrong rate does not care what the call cost.

Frequently asked

Quick answers

What is model routing?

Sending each request to the cheapest model that can handle it, instead of using one expensive model for everything — cutting cost with little quality loss.

What is a cheap-smart cascade?

Run a cheap model on every request, escalate to the expensive one only when the cheap answer is low-confidence.

When does a cascade save?

When the escalation rate is below break-even = 1 − c_cheap/c_big; a bigger price gap tolerates more escalation.

Router vs cascade?

A router predicts difficulty up front (no wasted cheap call, some mis-routing risk); a cascade runs cheap first and escalates (reliable, but pays cheap always).

Finished this one? 0 / 209 Handbooks done
NextLLM vs SLM Next on the “Serving models, and paying for them” ladder · rung 8 of 13

Explore the topic

See this alongside everything else on the same subject — handbooks, system designs, challenges and tools, in one place.

More Handbooks