How to Implement Model Routing Step by Step
Model routing sends each request to the model that fits it best, so simple questions get a cheap model and hard ones get a strong model. Here is how to build it.
On this page
Short answer
Model routing is a layer that scores each incoming request and sends it to the cheapest model that can handle it well. You implement it by defining your model tiers, writing routing rules, adding a fallback, and measuring cost and quality on real traffic before you trust it.
What is model routing?
Model routing is a layer in front of your models that decides, for each request, which model should answer it. A simple question goes to a small, cheap model. A hard question goes to a larger, stronger model. The user sees one endpoint and never knows which model answered.
The point is cost and quality together. Running every request on the strongest model wastes money, and running every request on the cheapest model hurts quality. Routing spends the expensive model only where it earns its keep.
Routing is not the same as load balancing. Load balancing spreads requests across copies of the same model. Routing picks between different models based on what the request needs. It is also different from fine-tuning: routing uses models you already have, while fine-tuning changes a model.
A routing layer usually has three parts: a scorer that reads the request, a set of rules or a small classifier that picks a tier, and a fallback that catches failures. For the cost side of the decision, model routing cost covers the numbers in more depth.
How does model routing work?
Model routing works by scoring each request before it reaches a model, then sending it to the tier that matches the score. The score can come from simple rules, a small classifier or the request itself.
The most common scoring signals are request length, topic, language, the user's plan and what the answer will be used for. A short factual question scores low. A long document that needs reasoning scores high. A request that will be shown to a customer scores higher than one used for an internal draft.
Most teams start with rules and add a classifier later. Rules are easy to explain and debug: if the request is under 50 words and matches a known pattern, use the small model. A classifier learns the same decision from examples, which helps when the patterns are hard to write down.
| Tier | Model size | Cost per request | Best for |
|---|---|---|---|
| Small | Compact model | Low | Short factual questions |
| Medium | Mid-size model | Medium | Drafts and summaries |
| Strong | Large model | High | Reasoning and customer answers |
The router also needs a fallback. If the chosen model fails, times out or returns a low-confidence answer, the request goes to the next tier up. Without a fallback, a routing mistake becomes a user-facing failure. See what is model routing for the basic concepts before you build.
How do you implement model routing?
You implement model routing by defining tiers, writing the routing decision, wiring it into your API and measuring the result on real traffic. Build it in that order, and do not skip the measurement step.
- Define your tiers. List the models you will use, what each one costs per request, and what each one is good at. Two or three tiers is enough to start.
- Pick your routing signals. Choose the request features that predict difficulty: length, topic, language, user plan and how the answer will be used.
- Write the routing rules. Start with simple if-then rules that anyone on the team can read, and keep them in one place.
- Add a fallback. If the chosen model fails or returns a weak answer, send the request to the next tier and log the event.
- Wire it into your API. Put the router in front of the models so every request passes through it, and log the tier chosen for each request.
- Measure on real traffic. Compare cost per request and answer quality before and after routing, on the same set of requests.
- Tune the thresholds. Move the cut-off points until the quality loss is small and the cost saving is real, then lock them in.
Keep the router separate from your application logic. If the router lives inside one service, other services will build their own copies, and the rules will drift apart. A small shared service or library is easier to keep consistent.
Example: routing support questions across two tiers
Example (hypothetical): a support product answers 100,000 questions a month. The strong model costs $0.02 per request and the small model costs $0.002. Without routing, every request uses the strong model, so the monthly bill is 100,000 x $0.02 = $2,000.
The team adds a router with two tiers. Simple questions, such as password resets and opening hours, go to the small model. The router sends 70,000 of the 100,000 requests to the small model and 30,000 to the strong model. The new bill is (70,000 x $0.002) + (30,000 x $0.02) = $140 + $600 = $740 a month, a saving of $1,260.
Quality is checked on a fixed set of 500 real questions. Before routing, the strong model answered 470 of 500 well. After routing, 462 of 500 are answered well, because the small model gets 8 of the routed questions wrong. The team accepts that trade: 8 questions in 500 for a 63% cost saving, and the 8 wrong answers are caught by the human review step.
The router itself costs little to run: a few rules and a small classifier. The main ongoing cost is the evaluation set, which the team refreshes every month with new real questions. For a related cost decision, small language model cost covers what the cheap tier really costs to run.
What should you measure after launch?
You should measure cost per request, answer quality and fallback rate. Those three numbers tell you whether routing is working or just moving the problem around.
- Cost per request. Total model spend divided by requests, before and after routing, on the same traffic.
- Answer quality. Score a fixed set of real requests every week, so the number is comparable over time.
- Fallback rate. The share of requests that move to a higher tier. A rising rate means the router is misjudging difficulty.
- Latency. Routing adds a small delay. Measure it, and keep it under the budget your users will accept.
- Tier mix. The share of requests each tier handles. A sudden shift usually means the traffic changed, not the router.
Review the numbers weekly for the first month, then monthly. Routing rules go stale as your product and your users change, so a threshold that was right in January may be wrong by June.
What are the common mistakes?
The most common model routing mistakes are too many tiers, rules nobody can explain, and no measurement at all.
- Starting with five tiers when two would do, which makes the rules hard to tune
- Routing on gut feel instead of a fixed evaluation set
- No fallback, so a routing error becomes a failed answer
- Hiding the router inside one service, so every team builds its own copy
- Measuring cost but never quality, so savings hide a worse product
- Letting thresholds drift without a scheduled review
- Routing on user plan alone, which sends hard questions to weak models for free users
When is model routing not worth it?
Model routing is not worth it when your traffic is small, your models cost nearly the same, or every request is hard. In those cases the router adds moving parts without saving money.
Skip routing if you have fewer than a few thousand requests a month, because the saving will not cover the build and maintenance time. Skip it if you only run one model, because there is nothing to route between. And skip it if quality is the only thing that matters, such as medical or legal answers, where a cheaper model is never the right trade.
Routing earns its keep when traffic is high, the cost gap between models is wide, and most requests are easy. That combination is common in support, search and internal tools, which is why those are the usual first places to add a router. If you are still choosing models, LLM development covers the wider decision.
Key takeaways
- Routing spends the expensive model only where it earns its keep
- Two or three tiers is enough to start; more tiers make tuning harder
- Every routing decision needs a fallback to the next tier up
- Measure cost per request and answer quality on the same traffic
- Review thresholds regularly, because traffic and users change
Frequently asked questions
How is model routing different from load balancing?
Load balancing spreads requests across copies of the same model to handle volume. Model routing picks between different models based on what the request needs. You can use both: routing picks the tier, and load balancing spreads the work inside that tier.
Do I need machine learning to build a router?
No. Most teams start with simple if-then rules based on request length, topic and user plan. A small classifier helps later, when the patterns are hard to write down. Start with rules, measure, and add a classifier only if the rules fail.
How much can model routing save?
It depends on your traffic mix and the price gap between models. If most requests are simple and the strong model costs ten times the small one, savings of half or more are realistic. Measure on your own traffic before promising a number.
What happens when the router picks the wrong model?
A good router has a fallback: if the chosen model fails, times out or returns a weak answer, the request goes to the next tier. Log every fallback, because a rising fallback rate means the routing rules need tuning.
Should routing decisions be visible to users?
Usually not. Users see one endpoint and one answer. Keep the tier choice in your logs, not in the user interface, so you can change the rules without changing what users see.
Can model routing work with models from different providers?
Yes. A router can send requests to models from several providers, which also gives you a backup if one provider has an outage. Just keep the cost and quality numbers per provider, because the same tier can behave differently across providers.