What is LLM routing, and how does automatic model selection work?
LLM routing is the practice of deciding, for each request, which model and which provider should serve it, instead of sending every request to one fixed model. Automatic model selection is routing where a router makes that choice for you: it inspects the request, estimates what the request needs, and picks a model from a pool of candidates. In FastRouter, setting the model to fastrouter/auto turns on automatic model selection, which weighs query complexity, domain or topic, and cost-efficiency.
Last updated
Key facts
- LLM routing chooses a model and a provider per request instead of using one fixed model.
- Model routing picks which model answers. Provider routing picks which provider serves that model.
- In FastRouter, setting model to fastrouter/auto delegates model selection to its routing engine.
- FastRouter's automatic selection weighs query complexity, domain or topic, and cost-efficiency.
- FastRouter can sort providers by price, latency or throughput through the provider object.
What is LLM routing?
LLM routing is a decision step placed in front of model calls. For each request, a router chooses which model should answer and which provider should serve that model, based on rules you set or on properties of the request such as difficulty, subject, price or speed.
Teams route because requests differ. A short classification prompt and a long multi-step reasoning task do not need the same model, and sending both to the most capable model costs more than necessary. Routing also helps with availability, because a request can be sent elsewhere when a model or provider is rate-limited or down.
What is the difference between model routing and provider routing?
Model routing decides which model answers a request. Provider routing decides which company's infrastructure serves that model, since many models are offered by more than one provider. The two decisions are independent: you can pin a model and still route between its providers, or do both automatically.
- Model routing affects output quality, capability and token price, because different models produce different answers.
- Provider routing keeps the model the same and changes who serves it, which mainly affects price, latency, throughput and availability.
- Fallback is a related mechanism: an ordered list of alternatives that is tried when the first choice fails.
How does automatic model selection work?
Automatic model selection replaces a hardcoded model ID with a router that picks the model at request time. The router reads the incoming messages, estimates what the request needs, compares the candidate models available to it, and forwards the request to the one it ranks best.
The inputs a router uses vary by product. Common ones are how complex the request is, what subject it covers, and what each candidate model costs. The application still sends an ordinary chat request. The only difference is that the model field names the router instead of a specific model.
The trade-off is predictability. With a fixed model, every request runs on the same model. With automatic selection, the model can differ from one request to the next, so it helps to be able to see which model was chosen.
How does FastRouter handle model and provider routing?
FastRouter routes at both levels. Setting model to fastrouter/auto delegates model selection to its routing engine, which picks from the available pool by query complexity, domain or topic, and cost-efficiency. Separately, a provider object on the request controls which provider serves a model.
Automatic selection needs no other configuration and no model preference lists. The request is a standard chat completions call to /api/v1/chat/completions. A model selection endpoint, /api/v1/model/selection, returns the selected_model, the top_candidates considered, the assigned_tags and the selection_strategy for a prompt without running the completion.
For provider routing, the provider object accepts order, only, ignore, sort, allow_fallbacks and require_parameters. The only and ignore fields narrow the eligible providers, order sets an exact sequence, and allow_fallbacks lets the request move to the next provider when the primary is unavailable. The sort strategies are compared below.
| Strategy | How to set it | What it selects |
|---|---|---|
| Default | Send no provider object | Favors providers that meet a performance and uptime threshold, weighted by the inverse square of price |
| Lowest price | sort: "price" or the :price model suffix | The least expensive provider for the selected model |
| Lowest latency | sort: "latency" | The fastest responding provider |
| Highest throughput | sort: "throughput" or the :throughput model suffix | The provider with the highest tokens-per-minute output |
When should you pin a model instead of routing automatically?
Pin a model when you need the same model on every request, for example when outputs must be reproducible, when a prompt has been tuned and evaluated against one model, or when a policy names an approved model. Use automatic selection when the right model depends on the request.
- Automatic selection suits mixed workloads where simple and complex prompts arrive at the same endpoint.
- A pinned model suits evaluated, regulated or regression-tested workloads.
- The two can be combined: pin the model and still route between the providers that serve it.
Sources
Where the statements about FastRouter on this page come from.