If you are running AI agents on a single frontier model, you are likely wasting 65% of your budget on tasks that don't require that level of intelligence. Developer Hassan Aziz outlines a practical architecture for an LLM model router that intercepts user requests, classifies their difficulty, and dispatches them to the cheapest capable model tier. The core thesis is simple: most business agent traffic is mundaneβformatting text, extracting JSON from invoices, or summarizing notesβand small models like Gemma 4 or Qwen 3.6 27B handle these tasks with precision at a fraction of the cost.
The Four-Step Routing Architecture
Aziz recommends a four-step build process starting with manual data labeling. Before writing code, you must label at least 500 real user prompts by task type and difficulty. This reveals that more than half of typical agent traffic is simple work. Next, establish three distinct tiers: Simple (for formatting and extraction), Standard (for writing and everyday code), and Frontier (for hard reasoning and debugging). Avoid over-engineering with more than three tiers, as each additional boundary increases the risk of misrouting. For the routing logic itself, Aziz advocates for an LLM-based classifier using a small, cheap model rather than brittle keyword rules or complex semantic embeddings.
Implementation and Escalation Logic
The implementation uses a lightweight Python script where a small model (like Haiku) acts as the router, reading the prompt and returning only a tier name. If the router fails to identify a tier, the request defaults to the standard tier for safety. Crucially, the system includes an escalation loop. An LLM judge scores the generated answer on a scale of 1 to 10. If the score falls below a threshold of 7, the request is escalated to the next tier up. This ensures that cheap models don't silently fail on edge cases. However, Aziz warns that if your escalation rate exceeds 20%, your routing logic is broken, meaning you are paying for two answers on every failed request.
Cost Analysis and Real-World Savings
In a test involving 12 prompts, the router achieved an 8% escalation rate and correctly routed 11 out of 12 requests. The simple prompts saw a cost reduction of approximately 65% compared to running everything through Opus. However, the total cost of the test run was higher with the router ($0.1128) than the baseline ($0.0791) because two complex frontier prompts dominated the bill. This highlights a critical nuance: savings depend entirely on the share of your spend going to simple work. If your agent handles high-volume, low-complexity tasks like ticket classification, the router is a massive win. If your traffic is low-volume but high-complexity, the overhead of routing and judging may negate the savings.
Key Takeaways
- Label at least 500 real prompts to understand your traffic distribution before building.
- Use a small LLM as the router instead of keyword rules to handle phrasing variations.
- Implement an LLM judge to score answers and escalate failures to higher tiers.
- Keep the escalation rate under 20% to avoid paying for duplicate answers.
- Savings are only realized if simple tasks make up a significant portion of your total spend.
The Bottom Line
Stop treating every token like it needs a PhD. Route the grunt work to the cheap bots and save your frontier models for the actual heavy lifting.