An AI application does not face the same problem on every request. One person may ask for a short rewrite. Another may submit a long contract for comparison. A third may need code analysis, structured extraction, or a decision that deserves careful human review. Sending every request to the most powerful model can make routine usage expensive, while sending every request to the cheapest model can create weak answers and extra correction work.
Model routing gives an application a way to choose a suitable model or provider for each request. The router can consider task complexity, response-time needs, privacy, availability, context length, and budget. It can send a small task to a fast model and reserve a stronger model for work that needs deeper reasoning. The goal is not to chase the lowest price on every call. The goal is to reduce the cost of a successful outcome without lowering the quality or safety threshold.
What model routing means in practice
A routing layer sits between the application and one or more AI models. The application sends a request to that layer instead of hard-coding one model into every feature. The router examines the request, applies a policy, selects a destination, and records the decision. Some systems use fixed rules. Others use a small classifier, a scoring service, or a sequence of increasingly capable models.
The destination may be another model from the same provider, a model from a different provider, a self-hosted model, or a regional endpoint. A routing policy can also send a request to retrieval, a tool, a human reviewer, or no model call. Cost is not only the price of generated tokens. It includes classification, retries, storage, monitoring, correction, and the time spent repairing an unsuitable answer.
Why sending everything to one model becomes expensive
Everyday AI traffic often contains a long tail of small requests. A user may ask for a sentence to be shortened, three fields to be extracted, or a known procedure to be restated. These tasks may not need a large context window or extended reasoning. If the application routes them all to a high-capability model, it pays a premium for capacity that the request does not use.
The opposite mistake is also costly. A cheap model may produce an answer that looks acceptable but needs several follow-up calls. A user may rewrite the prompt, correct the result, ask for missing evidence, or escalate the work to a specialist. The first call costs less, yet the complete task costs more. A routing trial should therefore measure cost per accepted result, not only cost per request.
Model choice can also affect latency. A compact model may answer a short request quickly, while a larger model may need more processing time. Fast responses can improve user experience for routine work. However, speed has little value when the answer requires extensive correction. Routing must protect a quality floor as well as a spending limit.
Start with workload categories, not model names
A useful router begins with the work the application performs. Create a small set of categories that a reviewer can recognise. For example, a support application might classify requests as short transformation, known-answer lookup, structured extraction, multi-document comparison, code reasoning, or high-impact recommendation.
The category should describe the required capability instead of the model brand. A short transformation may need a fast model with reliable instruction following. A contract comparison may need a longer context and better reasoning. A sensitive question may require a restricted provider or a local deployment. A request involving money, employment, health, access, or safety may need human approval regardless of which model handles the first draft.
Keep the first taxonomy small. Four or six categories are enough for an initial pilot. Add a category only when an existing rule cannot express a meaningful difference in capability, risk, or cost.
Use examples from actual traffic after removing personal data and secrets. Include easy requests, ambiguous prompts, long inputs, unusual wording, multilingual requests, and attempts to push the system beyond its approved role. A router trained only on tidy examples may fail when users phrase routine work in unexpected ways.
Choose a routing pattern that fits the application
The simplest pattern is static routing. One feature uses one model, while another feature uses a different model. This approach is easy to explain and works when workloads are stable. Its weakness is that it cannot adapt when a request changes in length, difficulty, or sensitivity.
A rules-based router uses signals such as token estimate, language, document count, customer tier, or feature type. Rules are transparent and inexpensive to run. They can become brittle when a short prompt hides a difficult problem or when a long prompt contains a simple task. Treat rules as useful evidence, not a complete understanding of intent.
A classifier-assisted router asks a small model or scoring service to assign a request to a capability tier. A gateway recipe from Kong demonstrates this pattern by analysing prompt complexity and selecting a faster or more capable route. [2] The classifier adds its own cost and failure mode, so its benefit must be measured against the money it helps save.
A cascade begins with a less expensive model. If the result fails a quality check, the request moves to a stronger model. The check may examine required fields, citation presence, format validity, confidence, or a lightweight evaluator. A cascade can work well for structured tasks, but the first model still consumes time and tokens. If escalation is frequent, a direct route may be cheaper.
Fallback routing addresses availability, not complexity. If a provider is unavailable, the request moves to an approved alternative. The fallback must respect data residency, privacy, output compatibility, and quality requirements. A failure route should not quietly send restricted information to a provider that the original policy excluded.
Define the signals a router may use
A routing decision should have an evidence trail. Useful signals include estimated input length, expected output length, task category, language, requested format, retrieval requirement, sensitivity label, user role, deadline, model health, and current budget. Do not collect a signal merely because it is available. Each signal should have a reason connected to a routing outcome.
Privacy deserves special attention. The request may contain customer details, internal documents, source code, or regulated information. A low-cost public endpoint may not be an acceptable destination. The router should apply data policy before it considers price. Cheaper is not a valid reason to cross a privacy boundary.
A quality signal can come from the request itself. Words such as “compare”, “explain the trade-off”, “find every inconsistency”, or “show your evidence” may indicate a task that needs more capability. Such words are not proof. They are clues that should be tested against labelled examples.
Health signals matter after routing. Track provider errors, timeouts, queue delays, rate limits, output length, and recent quality failures. A model that is cheap but unreliable can create retries and escalations. The router should be able to pause a destination when its service health or quality falls below the agreed threshold.
Measure savings without hiding quality loss
Build an evaluation set before changing production traffic. It should represent the main workloads, including routine requests and difficult cases. For each item, record the expected format, minimum acceptable answer, sensitivity class, and reviewer decision. Keep the evaluation set stable enough to compare routing policies over time.
Measure at least five outcomes. Record cost per request, cost per successful task, response latency, escalation rate, and correction effort. Add provider error rate, user satisfaction, and harmful or policy-breaking output where relevant. A routing policy is promising when total task cost falls without breaching the quality or safety floor.
Do not rely on one average score. A route may perform well for short rewrites and poorly for rare but important account questions. Break results down by category, language, document length, user group, and model destination. Examine the failures, not only the successful totals.
Track the cost of the router itself. A classifier call, an evaluator call, or a retrieval step may remove part of the expected saving. Include input and output tokens, cache use, storage, observability, and retries. If the router makes two calls before the selected model starts, those calls belong in the calculation.
Create a policy that people can inspect
A routing policy should be readable by engineers, product owners, security staff, and finance colleagues. State the categories, signals, thresholds, permitted destinations, forbidden destinations, fallback rules, and approval requirements. Include a named owner and a date for review.
Keep the policy separate from provider credentials. The application should not expose API keys to a classifier or allow a model to choose any destination it invents. Use an allow-list of approved models and providers. Record the selected route, policy version, model version, request class, and outcome without storing unnecessary prompt content.
A gateway can help centralise authentication, provider translation, routing, and spend information. Gateway documentation describes provider options, fallbacks, observability, and spend monitoring. [1] These are patterns to review, not configurations to copy without checking security and privacy.
Avoid routing mistakes that look like savings
Do not route by price alone. A low-cost model may lack the context length, language performance, tool support, or reliability required by the task. Do not route by prompt length alone either. A long document can need simple extraction, while a short request can require careful reasoning.
Do not allow the router to optimise a single number without constraints. If it minimises token cost while increasing correction work, the application has not become cheaper. If it lowers latency by sending sensitive content to an unapproved destination, the policy has failed. If it reduces escalation by accepting weak answers, the metric is misleading.
Watch for prompt manipulation. A user may describe a routine task as urgent or ask the router to ignore the sensitivity label. The model should not be the final authority for access, privacy, budget, or high-impact action. Deterministic checks and human ownership should remain around those boundaries.
Be careful with automatic retries. A timeout does not prove that the provider failed before processing the request. Retrying can create duplicate work or duplicate external actions. Use idempotency controls, bounded retry counts, and a clear distinction between a generated answer and an action taken through a tool.
Roll out model routing in stages
Begin in shadow mode. Let the router make a recommendation while the existing model continues to serve the user. Compare the recommended route with the actual result. This stage reveals classification mistakes while the user experience stays unchanged.
Next, route a small percentage of low-risk requests. Keep high-impact categories on their approved path until the policy has evidence behind it. Review cost, quality, latency, escalations, and complaints. Ask reviewers whether the chosen route made sense for the work, not only whether the final answer looked acceptable.
Expand gradually when the evidence remains stable. Keep a switch that returns traffic to the previous route. Record policy changes and model changes separately so that a later improvement or failure has a traceable cause. Re-evaluate after provider pricing, model versions, data policy, or application behaviour changes.
A routing experiment should have a stop condition. Pause it if quality falls below the agreed floor, a restricted data path appears, a provider becomes unreliable, or savings depend on hiding correction work. A reversible experiment is more valuable than a permanent policy built on one attractive number.
When model routing is worth the effort
Routing is worth exploring when the application serves varied workloads, model prices differ meaningfully, and the team can measure quality and correction effort. It is also useful when the application needs provider resilience, data-boundary rules, or separate paths for routine and high-stakes requests.
Routing may not be worthwhile when traffic is tiny, every request needs the same capability, or the routing layer would add more complexity than the expected saving. A single well-understood model with strong monitoring can be the better engineering decision. Compare maintenance, testing, incident response, and staff time as well as API spend.
NIST’s AI RMF asks teams to consider whether an AI system remains trustworthy throughout its lifecycle, from planning to assessment. [3] That principle applies to routing. Cost optimisation should sit inside a controlled system, not replace control.
