Model Routing

Model routing is the practice of sending each AI request to the model best suited to it, for example a small, fast model for simple tasks and a larger one for hard ones, to balance quality, cost and speed.

Also known as: LLM routing, model cascading, AI gateway routing

Related terms in this glossary

How it works

A router sits between the application and the models, often inside an AI gateway. It decides per request using one or more methods:

  • Rules: route by task type, customer tier, language or data sensitivity (for example, keep personal data on a self-hosted model).
  • Classifiers: a small model predicts how hard a request is. The 2024 RouteLLM research from LMSYS showed learned routers could keep most of a strong model's quality while sending many queries to a cheaper one.
  • Cascades: try the cheap model first and escalate if a check or confidence score fails.
  • Fallbacks: switch provider on errors, rate limits or outages.

Gateways such as LiteLLM, Portkey and cloud offerings provide the plumbing; the routing logic still needs your own evaluation data.

Why it matters

Using the most capable model for everything is simple but costly and often slower than needed. Many production requests, like classification, extraction and short replies, are handled well by smaller models. Routing captures those savings and adds resilience against a single provider's outage. The risks are quality regressions nobody notices and harder debugging. Every route should be backed by evals on real traffic, and traces should record which model answered each request. Routing also supports policy: sensitive data can be pinned to a model in a specific region. See AI cost optimization.

Model Routing in depth

Designing a router step by step

A router is only as good as the evidence behind each route. The sequence we follow:

  1. Inventory the traffic. Sample real requests and group them by task: classification, extraction, short answers, long analysis, code, tool-heavy agent steps.
  2. Build an evaluation set per group. Include easy, typical and hard cases, with grading rules.
  3. Score candidate models on each group. Record quality, latency and tokens used. Often a smaller model matches a large one on some groups and falls short on others.
  4. Write the simplest routing rule that works. Rules by task type or endpoint are easy to explain and debug. Add a learned classifier only if rules leave clear gains on the table.
  5. Add escalation. When a smaller model's output fails validation, such as a schema check or a confidence threshold, retry on a stronger model.
  6. Ship with tracing. Record the route, model and reason for every request.

Example: a support assistant with three tiers

Example: a customer support assistant receives a mix of messages. A small model classifies intent and language. Order-status questions, which only need a data lookup and a short reply, go to the small model. General product questions with retrieved passages go to a mid-sized model. Complaints, refund disputes and long multi-part questions go to a frontier model, or to a reasoning model with a modest thinking budget. Requests containing sensitive personal data are pinned to a self-hosted model in the company's own cloud region, regardless of difficulty. If any provider returns errors or rate limits, the gateway falls back to a pre-approved alternative with an equivalent evaluation score.

Measuring whether routing pays off

Compare a routed setup with the simple alternative, everything on one strong model, on the same evaluation set and on live traffic:

MeasureWhy it matters
Quality per task groupCatches regressions hidden by a good overall average
Share of requests per routeShows whether the lighter path is actually used
Escalation and fallback rateHigh rates mean the first tier is too weak
Latency at high percentilesCascades add time when they escalate
Running cost per completed taskThe real economic outcome, not cost per call

Our agent running cost tool helps estimate how routing choices change the cost profile.

Common mistakes

  • Routing on intuition without per-group evaluation.
  • Fallback models that were never tested on the task, so an outage silently lowers quality.
  • Prompts tuned for one model reused unchanged on another.
  • Cache-unfriendly routing: switching models mid-conversation discards prompt cache benefits.
  • No record of which model answered, which makes complaints impossible to investigate.

Where routing fits

Routing is part of LLMOps and usually lives in a model gateway. It works alongside prompt caching and token trimming as the main levers on token spend, and alongside data residency rules as a policy tool. Gepton designs routing in AI cost optimization and compares providers in technology and vendor evaluation.

Questions about Model Routing

Something else? Send us your question and an engineer replies with next steps.

Does model routing make an application harder to debug?

It can, unless every trace records which model handled the request, why the router chose it, and whether it escalated or fell back. With that information, debugging is similar to a single-model setup: you filter traces by route and replay failures. Keep routing rules in version control alongside prompts, and evaluate each route separately, so a quality problem can be traced to one tier rather than the whole system.

Can routing be used to keep personal data inside India?

Yes. Routing rules can send any request that contains personal data, detected by entity recognition or by which feature it comes from, to a model hosted in an Indian cloud region or on your own infrastructure. Other requests can use hosted models elsewhere if your policies allow. Detection must be reliable, so test it on real samples and default to the restricted route when unsure. Logs and caches must follow the same location rules.

Articles that mention Model Routing

All articles

Jump to

↑↓ to move↵ to open