The RouteLLM GitHub repository (lm-sys/RouteLLM) is an open-source framework for serving and evaluating LLM routers. A RouteLLM router sits in front of two models, a stronger, more expensive one and a cheaper, weaker one, and sends simpler queries to the cheap model. It scores each query with a learned function and sends the query to the strong model only when its score exceeds a threshold. The RouteLLM paper reports cost reductions of over 2x on public benchmarks without losing response quality. The catch is that the range of meaningful thresholds varies with the router and your queries, and the repository’s authors recommend calibrating it on a sample of your incoming queries.
So a router is not a cost switch you flip once. It is a policy fitted to a query distribution, and routers lose performance under distribution shift. The rest of this article covers how the policy is learned, how to calibrate it and how to tell whether it is still doing its job.
How a RouteLLM Router Scores Each Query and Applies the Cost Threshold
RouteLLM makes a binary decision before any answer exists: a lightweight scoring function looks at the incoming query, and any query scoring above the threshold goes to the strong model. Routing of this kind is pre-generation, which means it relies only on properties of the query and never sees a response. The scoring functions are designed to be computationally cheap compared with the models they route between, which is the whole point: a router that costs as much as the strong model defeats itself.
The threshold used for routing controls the cost-quality trade-off. Each request carries a cost threshold, and a higher threshold gives lower cost but may give lower-quality responses. In deployment, RouteLLM works as a drop-in replacement for OpenAI’s client, or you can launch it as an OpenAI-compatible server.
How RouteLLM Learns a Routing Policy from Preference Data
RouteLLM trains its routers on preference data: each record is a prompt plus a comparison of two models’ answers to it, scored as a win for one side or a tie. The main source is 80k battles from Chatbot Arena, where users vote on responses from two anonymous models. The training keeps only the identity of the winner, not the responses themselves. Models in the top two Arena tiers stand in for the strong class and third-tier models for the weak class.
Arena data alone left some routers close to random, so the authors augmented it in two ways. One used golden labels: roughly 1,500 MMLU validation questions, with a comparison label derived from which model got the answer right. The other used GPT-4 as a judge on queries from the Nectar dataset, producing about 120K preference samples for around $700.
The Four Router Types the Paper Compares
The RouteLLM paper (Ong et al., published at ICLR) trains and compares four router architectures:
- Similarity-weighted (SW) ranking: a weighted Elo calculation in which training queries count according to how similar they are to the incoming query, with similarity computed as cosine similarity between embeddings.
- Matrix factorisation: a bilinear function that maps a model embedding and a query embedding to a score for how well that model handles that query.
- BERT classifier: a fine-tuned BERT-base model that predicts which of the two models gives the better response, or whether they tie.
- Causal LLM classifier: a fine-tuned Llama-3-8B that rates on a 1 to 5 scale how hard the query would be to answer.
Out of the box, the repository supports four routers trained on the gpt-4-1106-preview and mixtral-8x7b-instruct-v0.1 pair, and it recommends the matrix factorisation router, mf.
The paper defines two metrics for measuring routers. Performance gap recovered (PGR) is the share of the quality gap between the weak and strong models that the router closes. Call-performance threshold, CPT(x%), is the smallest share of strong-model calls needed to reach a PGR of x%. On MT Bench, matrix factorisation trained only on Arena data reached 95% of GPT-4 performance with 26% of calls going to GPT-4, and with judge augmentation that fell to 14% of calls. On MT Bench, the BERT and causal LLM classifiers did close to random on Arena data alone, which the authors attribute to high-capacity models doing poorly with little data.
The headline numbers from the LMSYS announcement (2024) are cost reductions of over 85% on MT Bench, 45% on MMLU and 35% on GSM8K compared with using only GPT-4, at 95% of GPT-4’s performance. The paper’s own cost table, measured against a random-routing baseline at estimated GPT-4 and Mixtral prices, puts savings at up to 3.66x. Read these as research results on benchmark traffic with a fixed model pair, not as a forecast for your bill. Traffic with domain-specific edge cases can route very differently.
Two findings shape how much weight to put on the router architecture itself. First, the routers generalised to a new pair (Claude 3 Opus and Llama 3 8B) on MT Bench without retraining, which suggests they learned something general about what separates queries that need a strong model from those that do not. Second, a 2025 study comparing routing methods found that simple k-nearest-neighbour routing was competitive with, or better than, MLP and graph neural network routers, and ran 13-14x faster than graph and attention-based methods. In our view the choice of router architecture matters less than how well the router’s training data matches your traffic.
Is RouteLLM an Open-Source Framework You Run Yourself, and How Is It Different from Hosted Products That Use the ‘RouteLLM’ Name?
The RouteLLM GitHub project is code you deploy and operate: it gives you trained routers, a serving layer that speaks the OpenAI API, and an evaluation framework for measuring routing strategies on benchmarks. Unify, Martian, NotDiamond and others sell routing as a service, where the application sends its queries to the vendor’s router and the vendor picks the model and forwards the query.
The trade-off is ownership. A self-hosted router keeps routing decisions, logs and thresholds inside your stack, where you can inspect and recalibrate them, while a managed router gives you convenience and the vendor’s policy in exchange. The question of what routing gives you when you later swap model pairs is covered in how RouteLLM AI works as a cost-portability lever.
Routing Versus Cascading (FrugalGPT) Versus Always Calling the Strongest Model
Routing makes one decision per query, before generation, while cascading runs a smaller model first and moves up to a larger one only when a quality check finds the first answer lacking. Always calling the strongest model needs no decision at all: it gives the best answers and the highest cost.
FrugalGPT is an instantiation of the LLM cascade. It pairs a generation scoring function, which gives an answer a reliability score, with a list of LLM APIs, and returns the first answer whose score clears that step’s threshold. In one learned configuration, FrugalGPT accepted GPT-J’s answer if it scored above 0.96, otherwise tried J1-L with a threshold of 0.37, and fell back to GPT-4 after that. The FrugalGPT authors report matching the best individual LLM (e.g. GPT-4) with up to 98% cost reduction.
| Approach | When the model is chosen | Signal used | Cost on a hard query | Main way it goes wrong |
|---|---|---|---|---|
| Always strongest model | Never (fixed) | None | One strong call | Paying frontier prices for easy queries |
| Router (RouteLLM) | Before generation | Query only | One model call | Decides without seeing any response |
| Cascade (FrugalGPT) | After each attempt | Score of the generated answer | Cheap attempt plus strong call | Escalation drifts towards 100% |
| Cascade routing | Both, unified | Quality estimates | Depends on the estimator | Weak quality estimator |
Dekoninck et al. propose cascade routing, which combines both approaches into one strategy they prove optimal, and their analysis names good quality estimators as the factor that decides whether any model-selection approach succeeds. A pure router decides from the query alone, in return for a single model call. Where a wrong answer is expensive, you want a check after generation on the routed path, which makes the design part router and part cascade.
How Do You Calibrate a RouteLLM Cost Threshold Against Your Own Query Traffic?
Calibrate on a sample of your real incoming queries: choose the share of traffic you want on the strong model, then set the threshold that produces that share on the sample. Shafran et al. (2025) note that calibration queries must resemble the target workload. A threshold calibrated on Chatbot Arena did not transfer to MMLU and GSM8K, and about 98% of those queries went to the strong model. The RouteLLM results point the same way. On MMLU, routers trained only on Arena data performed close to random, and adding about 1,500 golden-label in-domain samples (under 2% of the training data) brought the best router, the causal LLM classifier, to 95% of GPT-4 performance with 54% of calls going to GPT-4.
Profiling the query traffic comes before setting the routing threshold. The order below is the one we would follow:
- Sample representative traffic. Draw queries from production logs across the sources, user groups and time windows that actually reach the router, not from a benchmark.
- Label a subset for your task. Run both models on it and record which answers are acceptable by your own criteria, since the paper itself suggests collecting a small amount of in-domain data for specific use cases.
- Pick a target strong-model share. Because queries scoring above the threshold go to the strong model, a target share ε puts the threshold at the (1 − ε) quantile of the sample’s router scores.
- Measure quality at that share. Compute PGR, the share of the weak-to-strong quality gap the routed path recovers.
- Freeze, deploy and watch the share. Log the live strong-model share against the calibrated target and recalibrate when it moves (see the next section).
When the Query Mix Changes
A 2026 study of natural prompt distribution shift found that the shifts correlate with LLM performance degradation after deployment, with geography showing the strongest shift and time-delayed data showing a large one too. Routers are affected directly: in the 2025 routing comparison every method lost performance under distribution shift, from 2.63 points for kNN to 6.67 points for linear matrix factorisation.
When the live strong-model share rises above the calibrated target, either the traffic has changed or the cheap model is being pushed beyond what it can handle. For neighbour-based routers, a cheap online signal is the distance to the k-th nearest training neighbour: queries unusually far from the training distribution point to sparse coverage and justify a fallback.
Shafran et al. showed that adversarial “confounder gadgets” added to queries can reroute them to the strong model, and they describe cost inflation as a kind of denial-of-service against applications that rely on routing to control spend. Per-user thresholds are one defence, but they complicate the implementation and can be circumvented by an attacker who creates new users.
How Do You Set a Reliability Floor and Track Escalation Rate for a Deployed Router?
Here, a reliability floor means the highest failure rate you will accept on traffic routed to the cheap model. You set it from what a failure costs downstream, not from the average accuracy of the strong model. Conformal routing calibrates the routing gate against such a floor, and its diagnostic ratio far above 1 means safe routing needs a very strong gate or is infeasible. The guarantee has two limits worth knowing before you rely on it. It holds on average over calibration randomness, not for each subgroup, so a particular topic can fail more often than the global bound, and it needs correctness labels for both models on a calibration set.
Escalation rate (the strong-model share) should be monitored like a service-level objective, because a verifier that is too strict, a formatting change on the provider’s side or drift in the cheap model’s output can push escalations towards 100%. Multi-model routers face a related failure, routing collapse. A 2026 study found that as the cost budget grows, routers systematically default to the most expensive model even when cheaper ones would do, and it traces this “routing collapse” to routers that predict scalar scores being used to make discrete comparisons. The same authors propose a Routing Collapse Index that measures how often a router makes a dominated choice or skips a cheaper model with comparable performance.
Routing on quality requires a way to measure quality. The practical options are offline evaluation sets, an online LLM-as-judge on sampled traffic, or A/B tests against business metrics, and a judge that shares the generator’s blind spots will approve its mistakes.
Metrics That Show a Router Is Saving Money Without Losing Reliability
Cost per resolved task is the measure to track, and it includes the verifier and the escalations. Wavect’s 2026 LLM cost calculator gives one formulation: routed cost = cheap path cost × (1 − escalation rate) + strong path cost × escalation rate + verifier cost. In a cascade, escalated requests also pay for the cheap attempt they made first. Dividing the routed cost by the number of tasks that actually ended up resolved, rather than by calls, keeps a cheap but wrong answer from counting as savings.
| Metric | What it tells you | Warning sign |
|---|---|---|
| Strong-model share (escalation rate) | Whether live routing matches the calibrated target | Steady climb with no change in traffic |
| PGR at the live share | How much of the weak-to-strong quality gap the router recovers | Lower than at calibration |
| CPT(x%) | Strong-model calls needed to hit a quality target | Higher than at calibration |
| Failure rate on cheap-routed queries, by subgroup | Whether the reliability floor holds where it matters | One topic or user group over the bound |
| Routing Collapse Index | Over-selection of expensive models | Cheaper models rarely chosen |
| Cost per resolved task | Spend per successful outcome, verifier included | Higher than at calibration |
| Drift signal (neighbour distance, prompt-distribution divergence) | Whether incoming queries still look like the calibration set | Growing share of far-from-training queries |
What a time-boxed RouteLLM trial should demonstrate before any production traffic moves is covered in RouteLLM proof-of-concept evaluation criteria.
Routing in Front of an LLM Planner
Routing is one of several cost and latency levers in the serving path that can be tuned without replacing the model, and it is worth trying before a model swap. In a robotics planner, if a planning step scored as easy goes to the cheap model and comes back wrong, the result is not a slightly weaker answer but a wrong plan handed to a physical system. Routing is safe in front of a planner when the cheap model’s output passes a check before execution (schema validation, constraint checks, simulation), when the floor has been measured on that robot’s own task distribution, and when steps relevant to safety are pinned to the strong model or a conformally calibrated gate whose subgroup failure rates have been checked. Without those conditions, a router cuts cost by quietly taking on risk the planner was never designed for.
TechnoLynx scopes routing economics and the reliability floor as part of a generative AI feasibility audit, before a router is wired into any planning path, within its generative and agentic AI R&D practice.
The broader question of how an LLM planner’s serving cost affects the return on a robot deployment is covered in our piece on deployable AI in robotics, and the latency limits of generative models in the control loop are discussed in how generative AI and robotics work together. Published RouteLLM results show routers reaching 95% of GPT-4 performance at lower cost on benchmark traffic. Only your labelled traffic tells you what the cheap model gets wrong in your domain and what each of those errors costs.