LLM model routing helps an application choose an appropriate model for each request instead of sending every task to the same endpoint. This guide provides a repeatable way to compare models by task quality, latency, cost, context, privacy, and reliability, then turn those criteria into a routing policy you can test and maintain as your workloads and provider inputs change.
Overview
Model routing is the practice of directing different AI tasks to different models or model configurations. A fast, lower-cost model may be suitable for classification, extraction, or short rewrites. A more capable reasoning model may be justified for complex analysis, ambiguous instructions, or high-impact decisions. A model with a larger context window may be needed for long documents, while a specialized embedding model may support retrieval in a RAG application.
The goal is not to identify one universally best model. It is to find the best model for each task under the constraints of your product. Those constraints usually include:
- Quality: Does the response meet the task's accuracy, reasoning, format, and safety requirements?
- Cost: What is the estimated spend per request and at the expected traffic volume?
- Latency: Can the model respond quickly enough for the user experience or workflow?
- Context: Can it handle the prompt, retrieved material, conversation history, and expected output?
- Privacy: Are the model, deployment route, retention settings, and data controls acceptable for the input?
- Reliability: Does the endpoint offer the availability, rate limits, structured output support, and SDK integration your system needs?
A routing strategy can be simple, such as assigning one model to summarization and another to complex reasoning. It can also be dynamic: a lightweight classifier first estimates task difficulty, then sends the request to a model that fits the request's requirements. In either case, routing should be treated as an engineering decision backed by a representative evaluation set, not by a general benchmark or a single impressive demonstration.
For related production concerns, see the LLM API cost and latency optimization checklist and the LLM evaluation framework guide.
How to estimate
Start by defining the unit you are comparing. Depending on the application, that may be cost per request, cost per completed workflow, cost per successful answer, or cost per active user. Cost per request is easy to calculate, but cost per successful answer is often more useful when models have different failure or retry rates.
A basic monthly estimate is:
Monthly model cost = requests × ((input tokens ÷ 1,000,000) × input price + (output tokens ÷ 1,000,000) × output price)
Use the current provider pricing for the specific model and endpoint when you perform the calculation. Keep input and output tokens separate because providers may price them differently. Add other usage-based components where relevant, such as embedding generation, reranking, tool calls, storage, or image and audio processing. If your provider uses a different billing unit, adapt the formula rather than forcing the calculation into token pricing.
Quality and latency need their own measures. For each candidate model, record:
- The percentage of test cases that meet the acceptance criteria.
- Median and high-percentile latency, measured under representative load.
- Average input and output tokens per request.
- Timeouts, rate-limit responses, malformed structured outputs, and retry frequency.
- Human review rate or downstream correction rate, if the workflow includes review.
Then compare candidates using a constraint-first approach. Eliminate models that fail a hard requirement, such as an unacceptable privacy condition, insufficient context, unsupported structured output, or a quality threshold. Among the remaining options, compare cost and latency. This prevents a low price from compensating for a model that cannot reliably complete the task.
A useful routing score can be expressed as:
Score = quality fit − cost penalty − latency penalty − operational risk penalty
The exact weights are application-specific. For a customer-facing assistant, latency may matter more than marginal cost. For overnight document processing, throughput and cost may dominate. For a compliance workflow, quality, traceability, and privacy may be hard constraints rather than weighted preferences.
Inputs and assumptions
Before comparing models, document the inputs that can change the result. A routing worksheet should include the following fields:
| Input | What to record | Why it matters |
|---|---|---|
| Task type | Classification, extraction, chat, coding, summarization, reasoning, retrieval, or agent step | Different tasks have different quality and latency requirements |
| Traffic | Requests per day or month, plus peak concurrency | Volume changes cost, rate-limit exposure, and capacity planning |
| Token profile | Typical and high-end input and output tokens | Long prompts and verbose outputs can change the preferred model |
| Quality threshold | Required score, pass rate, or human acceptance rate | Defines which models are viable |
| Latency target | Interactive target and maximum acceptable delay | A model can be accurate but unsuitable for the product experience |
| Context requirement | Prompt, history, retrieved documents, and tool results | Requests can fail or degrade when context is too large or poorly selected |
| Data classification | Public, internal, confidential, or regulated information | Determines which deployment and processing paths are acceptable |
| Fallback policy | Retry, alternate model, human review, or graceful failure | Routing must account for outages and model errors |
Do not rely on one average request. Measure at least a typical case and a difficult case. For example, a support summarizer may usually receive short tickets but occasionally receive long message histories. Routing based only on the average can produce failures at the upper end of the distribution.
Also separate model capability from prompt quality. Test the same prompt template, tool definitions, retrieval settings, and output schema across candidates. Version the prompt and evaluation set so that a change in results can be traced to the model, prompt, data, or routing logic. The prompt versioning workflow can help keep those changes auditable.
Worked examples
Example 1: Support ticket classification
Suppose an application assigns incoming tickets to a fixed set of categories and extracts a few fields into JSON. The task has short inputs, a predictable schema, high request volume, and a modest latency target. Begin with a fast model that supports reliable structured output. Test it against a labeled set containing ambiguous tickets, missing information, spelling errors, and multiple possible categories.
If the model meets the required pass rate, route all ordinary tickets to it. Send only low-confidence cases, schema failures, or tickets containing multiple issues to a stronger model or a review queue. This is often more efficient than using the stronger model for every ticket. Track escalation rate because it is part of the real cost of the routing policy.
Example 2: Long-document analysis
Consider a workflow that summarizes contracts or technical reports. The decision is not simply “which model summarizes best?” First determine whether the full document fits within the usable context after including instructions, metadata, and the expected output. If it does not, use document chunking, retrieval, or a staged summarization workflow. A RAG system may route retrieval and synthesis to different models, with an evaluation set checking both citation or evidence coverage and answer quality.
Compare the cost of one large-context request with the cost of several smaller requests plus retrieval or aggregation. Include failure handling and the extra latency of multiple calls. A cheaper individual call may not produce a cheaper completed workflow.
Example 3: Coding assistant with escalation
A coding assistant can use a fast model for autocomplete, simple explanations, and routine transformations, then escalate repository-wide changes or debugging tasks to a stronger reasoning model. The classifier can use explicit signals such as requested operation, number of files, tool count, test requirements, and uncertainty in the initial response.
For agentic tasks, evaluate the complete loop rather than only the final text: plan quality, tool selection, permission boundaries, recovery from errors, and whether tests pass. Review the tool-calling architecture guide before allowing routing decisions to trigger consequential actions.
A practical routing-policy template
Task: [name]
Default route: [model or model class]
Use when: [task conditions]
Hard requirements: [quality, privacy, context, schema]
Escalate when: [confidence, length, tool count, failure signal]
Fallback: [alternate model, retry, review, or safe failure]
Measure: [quality, latency, cost, escalation rate]
Review date or trigger: [condition]
Keep routing rules understandable enough for an engineer to inspect during an incident. A complicated scoring system is not automatically better than a short set of explicit rules.
When to recalculate
Recalculate model routing when any input to the decision changes. That includes provider pricing, model availability, context limits, API behavior, SDK support, rate limits, or published capabilities. It also includes changes inside your application: a new prompt, longer conversation history, higher traffic, new languages, additional tools, a different retrieval configuration, or a stricter quality requirement.
Review the policy after a meaningful change in traffic shape. A model that is economical at moderate volume may create operational issues during peak concurrency. Likewise, a model that appears expensive per request may reduce total spend if it lowers retries, escalations, or human corrections.
Use a standing maintenance cycle:
- Keep a fixed evaluation set for each important task and add production failures to it after removing sensitive data.
- Re-run candidates when pricing, models, prompts, retrieval, or traffic patterns change.
- Compare quality, latency, cost per request, cost per successful outcome, and failure rates.
- Test fallback paths, rate-limit behavior, structured outputs, and privacy controls.
- Deploy routing changes gradually and monitor escalation and correction rates.
- Record the decision, assumptions, test version, and next review trigger.
For reliability planning, pair routing with a documented LLM fallback and failover strategy. For sensitive workloads, review the data privacy and PII redaction guide. Model routing works best as a living part of AI model integration: measure it, version it, and revisit it whenever the economics or requirements move.