Tiered LLM Routing for Token Cost Optimization: A Practical Guide
As LLM applications move from prototypes to production, token spend quickly becomes a first-class engineering constraint: a single agent run can fire dozens of model calls, and a complex workflow can burn tens or even hundreds of thousands of tokens. This guide explains how to cut that cost without sacrificing quality by routing requests across model tiers, maximizing prompt-cache hits, and reverse-engineering real per-token prices from your own usage logs. It covers the three components of token billing, a four-tier routing design, a cost and budget formula, two high-leverage optimizations, a minimal routing framework you can implement yourself, and the pitfalls that quietly erase the savings.
1. Why Token Cost Is an Engineering Problem You Cannot Ignore
In the early days of building with LLMs, teams mostly asked one question: does it work? Once an application moves into production, the question changes fast — can we afford to keep it running? A single agent task can easily trigger dozens of model calls, and one complex workflow may consume tens of thousands or even hundreds of thousands of tokens. When volume grows from a few hundred calls a day to millions, differences that look negligible in the unit price get amplified enormously.
There is a second, more important factor: models at different capability levels are not priced on the same scale at all. The gap in output cost between a high-end reasoning model and a lightweight model is commonly orders of magnitude, not percentages. If you send every request to the same tier, you are effectively spending your most expensive resource on your cheapest tasks, and the budget disappears quickly.
So the goal of cost optimization is not “find the cheapest model.” It is letting the right model do the right work.
2. Understand the Cost Structure First: Three Dimensions
Before optimizing anything, it helps to know how token billing is usually broken down:
- Input tokens (prompt): everything you send as context — the system prompt, conversation history, retrieved documents, and so on.
- Output tokens (completion): what the model generates, typically billed at a noticeably higher unit price than input.
- Cached input tokens: when a request’s prefix closely matches earlier requests (a fixed system prompt, a long document referenced repeatedly), platforms can reuse a cache for that portion, and it is often billed at only a small fraction of the normal input rate.
Here is a lever that is easy to overlook: in many workflows, input dominates output — think 80% input and 20% output. Whoever can turn repeated input into cache hits opens up a very large cost gap. After a cache hit, that portion may cost on the order of one percent of the normal input price, which makes it the single biggest optimization opportunity on most bills.
3. The Core Idea: Tiered Routing, Each Model in Its Lane
The most effective architecture for this problem is tiered routing: dispatch requests to models of different capability and price levels based on task difficulty and stage. The whole principle fits in one line:
Let high-capability models do the thinking, and lightweight models do the work.
A typical tiered design looks like this:
- Planning and review (high-end models): task decomposition, solution design, and final quality review. These calls are infrequent and individually valuable, so an expensive model is a good trade.
- Complex reasoning (mid-tier models): subtasks that need real reasoning depth, balancing capability against cost.
- Main execution (standard models): most day-to-day generation, rewriting, code completion, and similar core work. This tier carries the bulk of the traffic, so its unit price has to be low.
- High-volume simple tasks (lightweight models): format conversion, classification and tagging, summarization — low difficulty, high frequency, easy to parallelize, where cost efficiency matters most.
The benefit is that a limited high-price budget gets spent exactly where it earns its keep, while everything else drops to a cheaper tier. Total cost can fall by one to two orders of magnitude with almost no impact on final quality.
4. Cost Modeling and Budget Planning: Control the Bill with a Formula
Once routing is in place, you need a quantifiable model to check whether it is actually working. The basic cost formula is:
total cost per call = input_tokens × input_price + output_tokens × output_priceSavings from the cacheable portion:savings = cached_tokens × (input_price - cache_price)
Budget planning works backwards from the constraint. If the platform limits usage with a fixed quota (for example, X credits per 5 hours and Y credits per week), you can estimate how much volume each tier can support. The following is an illustrative ratio — the numbers only demonstrate the method and do not represent any real product’s pricing:
Assume a budget of 600,000 credits per week, a workload of roughly 80% input + 20% output,and ignore caching for now.Let the combined per-token cost of high-tier : mid-tier : standard : lightweight= 200 : 56 : 6 : 1 (relative magnitudes)Under the same budget, the token throughput each tier can sustain scales roughly in inverseproportion, 200:56:6:1 —one pass on the high-tier model buys the lightweight model a hundred-plus passes.
The point of the example is that tiering is not about showing off an architecture. It is about making sure expensive models are worth their price: they run rarely, but every step counts, while cheap models absorb the overwhelming majority of throughput.
5. Two High-Leverage Optimizations: Caching and Batching
- Maximize cache hits. Put stable instructions (system prompt, tool definitions, long documents) at the front of the request and volatile content at the end. The more stable and the earlier a prefix is, the more likely it is to be reused from cache. On its own, this can cut input cost in half or more in many long-context scenarios.
- Batch simple tasks. For large numbers of homogeneous small tasks, hand them to a lightweight model and run them in parallel instead of letting the main model “just do it along the way.” Keep the task split clean so simple requests do not get mixed into complex flows and passively promoted to a higher tier.
6. Reverse-Engineer From Real Data Instead of Guessing
The most trustworthy source for unit prices and ratios is not a vendor price list — it is your own bill. A practical approach is a data-driven reverse calculation:
- For every call, record three numbers:
input_tokens,output_tokens, andcached_tokens. - Also record how your account quota (or spend) changed across that call:
Δquota. - Fit a linear relationship over many samples:
# Δquota ≈ a*input + b*output + c*cache_hit# Solve for (a, b, c) with least squares regression to get the model's# effective composite unit prices.
When the coefficient of determination R² is close to 1 and the residuals are close to 0, your usage logs and the billing logic agree closely, and the inferred unit prices can be trusted. The advantage of this method is that it reflects the actual cost of your real workload rather than a theoretical list price. And whenever platform rules or caching behavior change, you can refit and recalibrate the budget model quickly.
7. A Routing Framework You Can Actually Ship
Turning these ideas into an engineering design comes down to a task classifier plus a dispatcher. Below is generic illustrative logic, not a vendor-specific API:
def route_and_call(task):# 1) Profile the taskmeta = classify(task) # needs_reasoning / is_review / is_batch_simple / ...# 2) Pick a capability tierif meta.needs_deep_reasoning or meta.is_final_review:tier = "reasoning_tier" # planning, complex reasoning, final reviewelif meta.is_batch_simple:tier = "lightweight_tier" # batch, low difficulty, parallelizableelse:tier = "standard_tier" # main execution# 3) Put the stable prefix first to maximize cache hitsprompt = build_prompt(task, stable_prefix_first=True)# 4) Call, instrument, and write the usage log for later reverse calculationresp = invoke(tier, prompt)log_usage(task.id, tier, resp.usage) # input / output / cache_hitreturn resp
The supporting runtime pieces can be built from general-purpose cloud services: a log service to store per-call usage detail, monitoring and alerting to track quota burn rate per tier and warn on thresholds, a message queue to run batch tasks asynchronously in parallel, and object storage to keep long documents available for context reuse.
8. Common Pitfalls
- Do not downgrade everything at once. Moving review and planning onto a lightweight model means the money saved gets eaten by rework and quality loss. It is a bad trade.
- Watch out for the ignored “input-dominated” case. Many teams fixate on output price and forget that input is the bigger share, missing caching — the largest optimization available.
- Recalibrate the reverse-engineered model regularly. Billing rules and cache-hit policies can change at any time, so the cost model needs to be updated against fresh data rather than fit once and used forever.
- Distinguish measured figures from official ones. Prices inferred from your own bill represent your real usage profile, not the vendor’s standard pricing. Be explicit about that difference when budgeting or communicating externally.
9. Conclusion
Token cost optimization is not about hunting for the cheapest model. It is about building an engineering system with three parts: tiered routing, cache reuse, and data-driven reverse calculation. First, sort requests by capability tier so expensive models focus on planning and review while lightweight models absorb the bulk of execution. Then place the stable prefix first to maximize cache hits and bring down input, the largest cost center. Finally, fit a regression against your real bill to get trustworthy unit prices and keep recalibrating the budget. Do these three things, and you can cut overall call cost by one to two orders of magnitude while barely compromising quality — and make the application genuinely stable, sustainable, and affordable to run.
