deep · 6 min
Routing
Label the input first, then send it to the prompt, model or path built for that kind of input.
updated 29 Sept 2026
If we have a strong, expensive model and a weak, cheap one, how many of our users' questions actually need the strong one?
Hold on to that question. We'll get a real number for it in a bit. First, let's look at the plainer reason people route, which has nothing to do with price.
Four questions, four kinds of answer
Say we run a docs assistant for a learning site, and these come in on the same afternoon:
- "What is a KV cache?" wants one concept explained, from one article.
- "Reranking vs hybrid search?" wants two articles side by side.
- "How do I build a RAG chatbot?" wants a build plan across several concepts.
- "What's a good pizza place?" wants a polite "that's not what I'm for".
We could write one prompt that handles all four. The trouble is that every time we tune it to do comparisons better, explanations might quietly get worse. One prompt serving every kind of input ends up so-so at all of them.
Routing splits it in two. First, a router reads the question and returns one label from a fixed list. That step is plain classification. Then our code looks the label up and runs the path built for it: its own prompt, its own retrieval, its own output format. It's one of the LLM workflows, and probably the most common.
Now each path can be tuned and tested on its own, and a change to the comparison prompt can't hurt explanations.
There's a catch, and it's a big one. All of this only works if the router gets the label right. If it calls a comparison an explanation, the explanation path answers the wrong question, fluently and with full confidence.
Building the router
So how do we build the thing that picks the label? There are three common ways.
Ask an LLM. The simplest router is a prompt: here are the categories, one line each; here's the question; give a short reason, then one label. Anthropic's ticket-routing guide uses its fastest, cheapest model for this (Claude Haiku 4.5 as of 2026-09) and only moves up for many or subtle categories. A few dozen labelled examples can be enough, and when the categories change we just edit the prompt.
Find the nearest examples. We describe each route with a handful of example sentences, turn them into embeddings once, and for each new question pick the route whose examples sit closest. That's semantic search used as a classifier, with no LLM call at all. The semantic-router library works this way, and when nothing is close enough it returns no route, which gives us an off-topic signal for free. It's fast and cheap, but it understands less, and the "close enough" thresholds need tuning on labelled data.
Train a small classifier on our own labelled questions. It needs data up front, then it's cheap and fast on every call. Whether a fine-tuned small model beats an LLM router on our data is something we'd have to test. We couldn't find a published head-to-head.
Whichever we pick, the category list matters more than the method. The router can only be as accurate as the categories are clear. If two of them overlap, the router will keep confusing them.
Back to the price question
Everything so far was routing by kind: different questions need different handling. The other reason is routing by difficulty. The path stays the same and only the model changes: easy questions to a cheap model, hard ones to an expensive one. (Picking those two models is model selection.)
RouteLLM, from 2024, trained routers to choose between GPT-4 and Mixtral, which cost about a hundredth as much, one question at a time. They learned from human preference votes on which answer was better. A threshold sets how often the strong model gets called.
So here's our number. On a chat benchmark, the best router got to 95% of GPT-4's score while sending only about 13% of questions to GPT-4. To reach the same score by picking a model at random, we'd have needed GPT-4 for about half of them.
That works out to about 3.7 times fewer GPT-4 calls. On two other benchmarks (MMLU and GSM8K) the saving was smaller, around 1.4 to 1.5 times. And the router itself costs very little to run: the best one handled about 155 requests a second on a single L4 GPU, at around $3 per million requests.
Where routers go wrong
Traffic changes under them. Those RouteLLM routers were trained on chat conversations. On MMLU questions, which looked nothing like that, they did no better than random. Adding about 1,500 labelled examples of that kind (under 2% of the training data) fixed it. If our users start asking different things, the router's accuracy can drop and nothing will throw an error.
The label isn't one we expected. Anthropic's cookbook route() asks
for a label in an XML tag, pulls it out, and looks it up in a dictionary.
A typo or an extra word and that lookup fails, with nothing to catch it.
(The notebook says plainly that it's a demo.) Anthropic's prompting guide
now suggests returning the label through a tool with an enum of labels, or
structured output, so the answer can only be one of
our labels. And there should always be a default path.
Real questions don't fit one box. People ask indirectly ("I've been waiting for my package for over two weeks" is an order-status question), put two issues in one message, or lead with how upset they are. The ticket guide's fix is examples and explicit rules for these cases in the router prompt.
Too many categories. Past about 20, one router gets unwieldy. Routing in stages helps: first "technical, billing or general", then a smaller router under each. It's more accurate, but every level is another call before the answer even starts.
Every request pays for the router. It runs first, so its time is added to everything. A small model, an embedding router or a trained classifier keeps that cost low.
How do we even notice a bad route? A misrouted question doesn't crash. It gets a good answer to the wrong question. The only way to see it is to log the label next to every answer and look at them. The ticket guide's rough targets are 90 to 95% routing accuracy and fewer than one in ten requests needing to be rerouted. Every misroute we find is a new eval case.
And that 13% from earlier? It was GPT-4 against Mixtral, in 2024. The gap between cheap and expensive models moves with every release, so the right share for our traffic is a number we'd have to measure again each time either model changes.
Further reading
- Building effective agents, Erik Schluntz and Barry Zhang (Anthropic), 2024. Routing as a workflow shape, and the split between routing by kind and by difficulty.
- Ticket routing, Anthropic docs. A complete router, worked through. The section on edge cases is the most useful part.
- RouteLLM: Learning to Route LLMs with Preference Data, Isaac Ong et al., 2024. Where the 13% comes from, and the cost of running the router itself.
- Basic Multi-LLM Workflows,
Anthropic cookbook, 2025. A tiny
route()function. Read it and list what a real router would need on top. - Semantic Router, Aurelio AI. Routing by nearest example sentences, with no LLM call.
- Prompting best practices, Anthropic docs, current as of 2026-09. Why a label should come back through a tool enum or structured output.