What is an LLM router? Model, provider and fallback routing
The short version
- An LLM router takes requests on one API endpoint and decides which model, and which host of that model, answers each one. Your code names a model id; the router does the rest.
- On a single SQL-optimization prompt, 12 models wrote anywhere from about 900 to 6,441 output tokens. Pricier models tended to write more, so the real cost gap is wider than the gap in per-token rates.
- Routing is three separate decisions: which model, which provider, and what to do when the call fails.
- You can start without any clever automation. Keep model ids out of your code, in one map keyed by task.
What an LLM router does
You send a request with a model id as a string. Behind that endpoint, the router decides where the request goes: to a small model or a large one, to one host or another, and to a backup when the first choice is down. The caller sees one API and one request format.
Why route at all: the same prompt costs very different amounts
FastMetal keeps a comparison corpus: 43 prompts run against every model in the catalog. On 2026-08-31 it held 1,950 measured answers from 53 models. We took the 20 prompts written in Japanese and computed what each model's answer cost in output tokens. On every prompt, the gap between the cheapest and the most expensive answer was large.
Here is one of them, a request to optimize a SQL query. The table is sorted by what the answer cost, cheapest first. Per-token rates for each model are on its page in the model catalog.
| Model | Output tokens | Time |
|---|---|---|
mistral-voxtral-mini-3b-2507 | 1,108 | 4.6 s |
solar-pro4 | 1,114 | 44.7 s |
llm-jp-3.1-8x13b-instruct4 | 917 | 7.9 s |
deepseek-v4-flash | 3,026 | 61.4 s |
gpt-oss-120b | 2,901 | 13.3 s |
gpt-5.6-luna | 2,059 | 16.3 s |
anthropic-claude-haiku-4-5 | 1,184 | 7.4 s |
gemini-3.7-flash | 1,924 | 13.4 s |
glm-5.2 | 2,525 | 16.7 s |
anthropic-claude-sonnet-5 | 3,005 | 34.0 s |
anthropic-claude-fable-5 | 1,834 | 43.6 s |
anthropic-claude-opus-5 | 6,441 | 90.2 s |
Output ran from under 1,000 tokens to more than 6,000 for the same question. The bigger models tended to write longer answers, so the difference in length multiplies the difference in rate. What you pay per request spreads further apart than the price list suggests.
This table does not grade answer quality. The 90 seconds and 6,441 tokens from anthropic-claude-opus-5 are partly the cost of a careful answer to a hard question. The point is narrower: sending every request to the top model costs more than most teams expect. The cost calculator runs the same comparison for your own workload.
The three layers of routing
"Routing" covers three decisions that behave differently.
1. Model choice
Which model gets the request. Small models for tagging and classification, large ones for design decisions and long rewrites. The table above is the argument for doing this.
You can automate it, but you do not have to start there. The gap is large enough that choosing a model per task by hand already pays off.
2. Provider choice
The same open model can behave differently depending on who serves it: quantization, context length and uptime all vary by host. Two endpoints that both say "Kimi K3" can return different results.
3. Fallback
What happens when the target is down, or the model is retired. This risk is real. A preview model in the FastMetal catalog once ended without notice and returned errors for a while afterward. If your app hard-codes one model id, that is the day it stops working.
Router versus gateway
The two terms show up in the same conversations, but they cover different scopes.
- An AI gateway is the front door. It handles the cross-cutting work: authentication, billing, logging and rate limits.
- A router is the dispatch logic inside it, the part that decides where each request goes.
Most products do not separate the two. FastMetal is an AI gateway with routing built into the same endpoint.
Since this was first written: auto
FastMetal now routes for you if you ask it to. Send model: "auto" and the gateway picks the cheapest model that can handle that request's needs (tools, images, JSON output), and falls back to the next candidate if the call fails. You are billed at the rate of the model it chose. auto-medium, auto-hard and auto-max do the same with a higher minimum quality level. Manual routing, below, still makes sense when you want a fixed model per task.
Route by hand in a few lines
The first step is to get model ids out of your code. With an OpenAI-compatible API the model is one string, so switching models is a config change.
from openai import OpenAI
client = OpenAI(
api_key="sk-...",
base_url="https://api.fastmetal.ai/v1",
)
ROUTES = {
"classify": "gemma-4-26b-a4b-it",
"draft": "anthropic-claude-haiku-4-5",
"review": "anthropic-claude-sonnet-5",
}
def ask(task: str, prompt: str) -> str:
res = client.chat.completions.create(
model=ROUTES[task],
messages=[{"role": "user", "content": prompt}],
)
return res.choices[0].message.content
print(ask("classify", "Classify this support ticket: my invoice never arrived."))
With ROUTES as a dictionary, swapping a model is an edit to one line. Adding fallback is the same shape: make each value a list of candidates and try them in order.
What makes this work is that every candidate takes the same request format. If each provider needs its own SDK, every switch is a rewrite, and in practice nobody switches.
Takeaways
- An LLM router picks the model, the provider and the fallback for each request behind one endpoint.
- On the same prompt, the real cost gap between models was wider than the gap in their rates, because pricier models wrote more.
- A dictionary of model ids per task is enough to start.
- Models get retired. Decide your fallback before you need it.
One FastMetal key calls every model in the catalog in the same format, and auto does the routing when you would rather not. Rates are on pricing.