Learn

Architecture & pattern guides

Read the idea, build it on a Grid, prove it in a challenge. Short, practical guides — illustrated with RodGrid's own nodes — on system design, design patterns, flow modeling, and how to get the most out of the app.

All articles

Model routing & cascades: the cheapest model that can answer

Why sending every request to the strongest model pays for answers a cheaper one already gets right, and how to choose per request: rules and a difficulty classifier before the call, a cascade that checks a cheap model's answer and escalates the failures, what each costs, and the escalation rate as the number to watch.

Ninety-one percent for a twentieth of the price

A bookkeeping product for small businesses suggests a category for every bank transaction it imports: Software, Travel, Owner's drawings, one of the accounts in that business's chart of accounts. Every suggestion comes from the provider's largest model. One week the team takes 1,000 transactions that customers' accountants had already confirmed and also runs them through a small model priced at a twentieth as much per token (a round ratio, not any provider's list price). The large model matches the accountant on 960. The small one matches on 910.

Put the other way, the product pays twenty times the price on 910 transactions in 1,000 for an answer the cheap model gets right anyway. Most transactions are easy: AWS EMEA is software, TFL TRAVEL CHARGE is travel. The large model earns its price on a transfer with the memo REF 22817 J.M., which might be a supplier, a salary or the owner paying themselves, and even it gets some of those wrong.

Finding the hard ones

Switching everything to the small model would buy the saving with 50 more wrong categories per thousand, each one for an accountant to catch and fix by hand. The useful move is to send each transaction to the cheapest model that can answer it, and you do not know which transactions are the hard ones until something has looked at them.

Model routing is choosing the model per request. There are two moments to choose: before any model sees the request, from what you can tell about it, or after a cheap model has answered, from what you can tell about the answer. Most real systems use both.

Sorting before the call

Some decisions are plain rules read from the request. The month-end report, a paragraph explaining why this month's costs differ from last month's, always goes to the large model: one call per business per month, and its prose is what the owner reads. A statement with forty line items to categorise in one call goes large too, because in the team's sample the small model's mistakes grew with input length. A plan that sells premium categorisation routes its tenants large by contract. Rules are cheap and predictable, and they only see what the request shows.

A rule can recognise a known vendor such as AWS EMEA, or flag a memo that names none; it cannot say how likely the small model is to get REF 22817 J.M. right. A router estimates that: a small classifier, often not a language model at all, trained on past transactions labelled with whether the small model's category was confirmed. It returns how likely the small model is to be right; above a threshold the request goes small, below it large. It costs far less than a call to either model, but its mistakes are silent: a hard transaction misjudged as easy gets the small model's answer, and nothing looks at it again.

Try small, check, escalate

The other moment is after the answer. A cascade sends the request to the small model first, checks what comes back, and only when the check fails sends the same request to the large model: it escalates. The design rests on the check, which here can be three things, from cheapest to dearest:

  • Validation in code. The answer must parse as the expected structure, and the category must exist in this business's chart of accounts. It catches malformed output and invented categories for free, and cannot catch Travel for what was really Meals, because both are valid.
  • A confidence signal. Where the API exposes token probabilities, the probability given to the chosen category, combined across its tokens when it spans several, is one; a score the model writes about itself is another. Neither can be trusted until compared against labelled data, since models are often confident when wrong, so the threshold comes from measurements, not from the number's face value.
  • A verifier model. A second call asks whether the category fits the memo and amount. It catches some plausible mistakes the others miss, at the price of a call on every request, and a verifier closely related to the model it checks tends to share its blind spots.

The team uses the first two: invalid output escalates, and so does a category whose probability falls under a threshold chosen on the 1,000 confirmed transactions. A missing probability counts as a failed check; counting it as a pass would let every answer through the day a provider stops returning the field.

Small first, large on a failed check

The gateway's route tries the small model, validates the answer and its probability, and escalates only failures. Each trace records which model answered.

What escalation costs

A cascade pays twice for every request it escalates: the small call that failed, then the large one. Take both models reading and writing the same tokens, and a check that costs nothing. Against sending everything large, the cascade costs the small model's share on every request (5%) plus the large model's full price on the escalated fraction. At 12% escalated, the bill is 17% of the all-large one; at 50%, 55%; past 95%, more than having no cascade.

Latency adds up the same way: an escalated request waits for the small model, the check and the large one, while the rest wait only for the small model and the check. Categorisation runs in the background, so the extra seconds bother nobody here. An answer someone waits for is different: a check that reads the whole answer cannot let it stream to the reader until it has passed. That is where a router earns its place in front of a cascade: what it predicts is hard skips the small attempt and pays once.

Proving the cheap path, then watching it

A cascade's accuracy is set by two things: the small model's mistakes its check lets through, and the large model's own mistakes on the requests it escalates. A confident wrong Owner's drawings passes the check and sails into a tax return, and a correct small answer that the check rejects can come back wrong from the large model. So before it goes live the team compares it with the large model alone on confirmed transactions, category by category, because rare errors can cluster in the few categories a tax return cares about; building that set and gating every route change on it is Evaluating LLM output: golden sets, judges & release gates.

In production, the number to watch is the escalation rate, per feature and per tenant, read from traces that record which model answered. In March it climbs from 12% to 30% in a week: a large bank changed its memo format, and the bill doubles while accuracy holds. A sudden fall needs the same look: easier traffic can explain it, and so can a check that has stopped checking.

Inside the gateway

The routing belongs in, or right beside, the LLM Gateway every model call already passes through: the categoriser asks for the route categorise-transaction, and the route holds the rules, the router's threshold, the two models and the check, so changing any of them changes no caller. Escalation is not fallback. Fallback sends the request to another provider because the first failed to answer; escalation sends it to a stronger model because the answer failed the check. Fallback and the budgets that must also cover an escalated call are Serving LLMs: gateways, fallback & token budgets.

Which transactions need the large model?

That is the question AI Cost Control for a Multi-Tenant SaaS makes you answer for a whole SaaS, and its deep-dive stage asks the sharper one: when is a cascade cheaper than sending everything to the strong model? Your Grid answers it with two models behind the LLM Gateway, the check named on the edge between them, and, beside it, the escalation rate you expect and the share of the all-large bill that rate leaves you paying.

Practice this