Routing: send each input to the model that should handle it
Classify the incoming request first, then dispatch it to a specialised prompt or model. Separation of concerns for AI workflows — and a quiet way to cut cost.
When one prompt has to handle wildly different kinds of input, it ends up mediocre at all of them. Routing fixes that: a first step classifies the input, then hands it to a follow-up that's specialised for exactly that category. It's separation of concerns applied to AI workflows.
How it works
The router is usually a small, cheap model (or even a classifier) whose only job is to pick a category. Each downstream path then gets a prompt tuned for its case — and optionally a different model. Simple queries go to a fast, cheap model; hard ones go to a frontier model. You optimise each path without any one of them dragging down the others.
- Each handler is tuned for one category, so quality rises across the board.
- Route easy traffic to cheap models and reserve frontier models for hard cases.
- Add a new category by adding a route — no risk of regressing the others.
const category = await router(input); // 'billing' | 'tech' | 'sales'
switch (category) {
case 'billing': return billingAgent(input);
case 'tech': return techSupportAgent(input);
default: return salesAgent(input);
}When to use it
Use routing when inputs fall into distinct classes that are best handled differently — support triage, multi-language handling, or tiering by difficulty. The one thing to watch: the router is now a dependency. Measure its accuracy, because a misroute sends the request down the wrong path entirely.
Don't build one prompt that's average at everything. Route to the one that's excellent at the thing in front of it.