AI

LLM Routing: Send Each Prompt to the Right Model

LLM routing explained: how an LLM router picks a model per prompt, routing strategies, research results, cost math, code, evaluation and common pitfalls.

By OmniAI Editorial · Nov 22, 2026 · 12 min read

LLM routing means sending each request to the language model best suited to it, instead of sending everything to one model. An LLM router looks at the prompt (its task, difficulty, length, required tools, privacy constraints) and picks a model: a small, cheap, fast model for easy requests and a large, expensive one for hard ones. Done well, routing cuts cost and latency substantially while keeping quality close to the strongest model, which is why it now appears in research, in AI gateways and inside products such as GPT-5. Done badly, it quietly sends hard questions to weak models.

This guide explains how LLM routing works, the main LLM routing strategies, what research has measured, a worked cost example, a simple router in code, LLM router vs LiteLLM and gateways, how to evaluate a router, and the pitfalls to avoid. If you're new to the cost side, our guide on how to reduce LLM costs covers routing alongside caching, batching and prompt trimming; this post goes deeper on routing itself.

What Is LLM Routing?

An LLM router is a decision layer between your application and a pool of models. For every request it answers one question: which model should handle this?

It's different from two neighbouring ideas:

  • Load balancing spreads traffic across equivalent copies of the same model to share load. Routing chooses between different models with different strengths and prices.
  • An LLM gateway is infrastructure in front of model providers: one API, keys, logging, rate limits, caching, fallbacks. A gateway can contain a router, but the router is the decision; the gateway is the plumbing. Our LLM gateway guide covers that layer.

Routing pays off because models differ enormously in price and speed. Within one provider's line-up, the flagship model often costs many times more per token than the small model, and across providers the spread is larger still. Most real traffic is a mix: plenty of easy requests (classify this, reformat that, answer a short factual question) and a minority of hard ones (multi-step reasoning, long code changes, nuanced writing). Paying flagship prices for all of it wastes money.

Why Route Between Models?

  • Cost: send easy requests to cheaper models.
  • Latency: small models answer faster, which matters for chat, autocomplete and voice.
  • Capability: some models are better at code, others at long documents, others at specific languages or vision.
  • Reasoning effort: route only hard problems to reasoning models or high reasoning settings, which are slower and costlier.
  • Availability: fail over to another model or provider during outages or rate limiting.
  • Privacy and compliance: keep sensitive requests on a self-hosted or regional model, and send the rest to a hosted API.

How LLM Routing Works

How LLM routing works in practice can be broken into four steps:

  1. Inspect the request. Extract features: the text, its length, the task type, the user's tier, whether tools or images are involved, and any data-sensitivity flags.
  2. Decide. Apply rules, a classifier, an embedding similarity search, or a small model that predicts which candidate will answer well enough.
  3. Call the chosen model. Format the request for that model's API and send it.
  4. Optionally verify and escalate. Check the answer (format validation, a confidence score, a judge model, a test run for code). If it fails, retry with a stronger model.

Learned routers are trained offline on data showing which model answered which kind of prompt well, for example human preference votes comparing a strong and a weak model's answers, or judge-model ratings. The trained router then makes a fast prediction at request time.

A light box holding a grey magnifying glass, an ink arrow to a grey box, and three curved lines to light chips of increasing size, the top line in orange.
Inspect the request, decide, call the chosen model, and escalate if the answer fails a check.

LLM Routing Strategies

StrategyHow it decidesStrengthsWeaknessesGood for
Static or task-basedA fixed model per feature or endpointSimple, predictable, easy to testIgnores per-request difficultyProducts with distinct features
Rule-basedHeuristics: length, keywords, user tier, presence of code or imagesCheap, transparentBrittle; misses subtle difficultyEarly-stage products, clear-cut cases
Semantic routingEmbeds the prompt and compares it with example prompts for each routeFast, handles paraphrasesNeeds good examples; drifts as traffic changesIntent-based routing, topic routing
Learned classifierA trained model predicts whether the cheap model is good enoughCaptures difficulty; tunable thresholdNeeds labelled or preference dataHigh-volume, mixed-difficulty traffic
CascadeTry the cheap model first; escalate if a check failsPays strong-model prices only when neededAdds latency on escalations; needs a reliable checkTasks with verifiable outputs (JSON, code, extraction)
LLM as routerA small LLM reads the prompt and picks a model or toolFlexible, easy to change with instructionsAdds a model call; can be inconsistentAgents choosing among tools and models
Cost and latency awarePicks among acceptable models by current price, speed or loadOptimises spend and responsivenessRequires live metricsMulti-provider setups
FallbackSwitches model on errors, timeouts or rate limitsImproves uptimeNot about quality or costEvery production setup

Real systems combine several: a rule sends images to a vision model, a classifier splits text requests between a small and a large model, a cascade validates structured outputs, and fallbacks handle outages.

What the Research Shows

Routing has a growing body of research and production examples. A few well-documented results:

WorkApproachReported result
FrugalGPT (Chen, Zaharia and Zou, Stanford, 2023)Learned cascade across several LLMsMatched the best single model (GPT-4) with up to 98% cost reduction, or improved accuracy by 4% at the same cost, on the tasks studied
RouteLLM (LMSYS, UC Berkeley and Anyscale, 2024)Routers trained on Chatbot Arena preference data to choose between a strong and a weak modelCost reductions of over 85% on MT Bench, 45% on MMLU and 35% on GSM8K versus using only GPT-4, while achieving 95% of GPT-4's performance
RouteLLM matrix factorization routerOne of the trained routersReached 95% of GPT-4's performance using 26% GPT-4 calls on MT Bench when trained on Arena data alone, about 48% cheaper than a random baseline
GPT-5 (OpenAI, 2025)Built-in router in a consumer productA "real-time router" decides between a fast model and a deeper reasoning model based on conversation type, complexity, tool needs and explicit intent, and is trained on signals such as model switches, preference rates and measured correctness
OpenRouter Auto RouterHosted router across many providersPicks a model and a reasoning effort per request within the user's provider and data-retention constraints; a variant is tuned for coding agents

The research numbers are benchmark results with specific model pairs, so your savings will differ. They show the shape of the opportunity: on mixed traffic, a large share of requests don't need the most expensive model.

Worked Example: The Cost Math

Suppose an app handles 1 million requests a month at an average of 2,000 tokens each (2 billion tokens). Use illustrative prices: a strong model at $10 per million tokens and a small model at $0.50 per million tokens (real prices vary widely; plug in your own).

SetupStrong model shareSmall model shareMonthly costSaving vs strong-only
Strong model only100%0%$20,000—
Router sends 70% to the small model30%70%$6,000 + $700 = $6,70066.5%
Router sends 50% to the small model50%50%$10,000 + $500 = $10,50047.5%
Cascade: everything tries small first, 30% escalate30%100% (first attempt)$6,000 + $1,000 = $7,00065%

Three things the table hides:

  • Quality. The saving is only real if the routed requests are answered well. Measure it.
  • Latency. The cascade pays two calls for escalated requests; the classifier router adds a small decision step to every request.
  • Router cost. A rule costs nothing; an embedding lookup costs very little; an LLM-as-router adds a model call per request, which can eat into savings on short prompts.

Building a Simple LLM Router

A basic router can start as a few lines of logic. This sketch combines rules, a difficulty score and a fallback; classify_difficulty and call_model stand in for your own classifier and model client:

CHEAP, STRONG, VISION = "small-model", "large-model", "vision-model"

def choose_model(request):
    if request.get("images"):
        return VISION
    if request.get("contains_sensitive_data"):
        return "self-hosted-model"  # keep regulated data in-house
    score = classify_difficulty(request["prompt"])  # 0.0 easy ... 1.0 hard
    return STRONG if score >= 0.6 else CHEAP

def route(request):
    model = choose_model(request)
    try:
        answer = call_model(model, request)
    except (TimeoutError, ConnectionError):
        model = STRONG
        answer = call_model(model, request)  # simple fallback
    if model == CHEAP and not passes_checks(answer):
        answer = call_model(STRONG, request)  # cascade: escalate on failed checks
    return answer

The difficulty score can begin as heuristics (prompt length, presence of code, words such as "prove" or "step by step") and later become a trained classifier using your own logs: store each prompt, the model used and whether the answer was accepted, then train on that. The threshold (0.6 here) is the dial between cost and quality.

LLM Router vs LiteLLM and Gateways

People comparing an LLM router vs LiteLLM are usually comparing two layers. LiteLLM is an open-source SDK and proxy that gives many model providers one OpenAI-style API, with features such as keys, budgets, logging, retries, fallbacks and load balancing across deployments. Its routing features mostly decide where to send a request for a given model (which deployment, which provider, what to do on failure), based on load, latency, cost or errors.

A quality-aware LLM router decides which model should answer a given prompt based on its content. You can run one in front of, or inside, a gateway like LiteLLM: the router picks "small" or "large", and the gateway handles provider keys, retries and logging for whichever it picked. Hosted gateways such as OpenRouter now offer both: a unified API plus an automatic router.

Two light layers joined by an ink line: the upper holds a grey box with an orange arrow, the lower and wider holds three grey blocks linked by ink lines.
The router chooses the model; the gateway beneath it handles providers, keys and retries.

How to Evaluate an LLM Router

A router is only as good as the evidence that it doesn't hurt quality. Evaluate it like any model change; our LLM evaluation guide covers the methods.

  • Build a representative test set from real, anonymised traffic, including the hard tail.
  • Run every prompt through each candidate model and grade answers with tests, references or a judge model plus human spot checks.
  • Plot a cost-quality curve: for each router threshold, the cost and the quality score. Pick the point that meets your quality bar at the lowest cost.
  • Measure the quality gap recovered: how much of the difference between the cheap and strong model's scores the router keeps, at a given share of strong-model calls. RouteLLM reports results this way.
  • Watch for regressions by segment: a router can look fine on average while failing a specific customer or task type.
  • Monitor in production: track escalation rates, user feedback, retries and per-route quality over time, because traffic changes.

Common LLM Routing Pitfalls

  • Misrouting the hard tail. Short prompts can be hard ("prove this lemma"), and long prompts can be easy. Don't route on length alone.
  • Distribution shift. A router trained on last quarter's traffic may misjudge new features or new users.
  • Inconsistent behaviour. Different models have different tones, formatting habits and refusal patterns. Users notice when answers change style mid-conversation; consider routing per conversation rather than per message.
  • Tool-calling differences. Models differ in how reliably they call tools and follow schemas, so agent workflows need per-model testing.
  • Breaking caches. Prompt caching works per model; switching models mid-session can lose cache discounts and raise latency.
  • Hidden router costs. An LLM-based router on every short request can cost more than it saves.
  • No fallback for the router itself. If the classifier service fails, default to a safe model rather than failing the request.

LLM Routing Companies and Tools

The landscape changes quickly, so think in categories:

  • Built into model products: assistants and APIs that route internally between fast and reasoning modes, such as GPT-5's router.
  • Hosted routers: services that predict the best model per prompt across providers, often with a dashboard to trade cost against quality.
  • Gateways with routing: OpenRouter's Auto Router, and gateways such as LiteLLM and others that offer fallbacks, load balancing and rule-based routing.
  • Open-source frameworks: research code such as RouteLLM, semantic-routing libraries, and the routing features inside agent frameworks.
  • Build your own: rules plus a small classifier trained on your logs, which often captures most of the savings for a single product.

FAQ

What is an LLM router?

An LLM router is a component that chooses which language model should handle each request, based on the request's content, difficulty, cost limits, latency needs or data constraints. It sits between your application and the models.

How much can LLM routing save?

It depends on your traffic mix and the price gap between models. Research benchmarks report savings from about a third to over 85% while keeping most of the strong model's quality, but you should measure on your own data before relying on a number.

Is LLM routing the same as an LLM gateway?

No. A gateway is infrastructure for calling many providers through one interface, with logging, keys and fallbacks. A router makes the decision about which model to use. Many gateways include routing features, and routers are often deployed inside gateways.

Does routing reduce answer quality?

It can, if the router sends hard requests to a weak model. Good routers are tuned against a quality bar on real test data and monitored in production, so the drop is small or zero for the traffic they route.

When shouldn't I use LLM routing?

When traffic is low (savings are small), when every request is hard, when consistency of style matters more than cost, or when you can't measure quality. Start with one well-chosen model and add routing once volume and evaluation are in place.

All articles

Read next

Language

EnglishEnglish · en TürkçeTurkish · tr DeutschGerman · de العربيةArabic · ar

Account

Enter your email. We’ll send you a sign-in link and a 6-digit code. No password needed.

Sign in

Theme

Language

Show our email address

To keep spam out of our inbox, please confirm your own email first. We will send you a 6-digit code.

We send codes only to these providers: gmail.com, googlemail.com, outlook.com, hotmail.com, live.com, msn.com, proton.me, protonmail.com, pm.me, icloud.com, me.com, mac.com, yahoo.com, aol.com, gmx.de, gmx.net, web.de, t-online.de, yandex.com, omniai.blog