LLM API Cost Measurement and Tiered Model Routing: A Practical Guide
This article presents a practical method for reverse-engineering the token cost of different LLM service tiers from a small set of real API calls. It explains how to fit input, output, and cache-hit rates, estimate available throughput from a quota pool, and design a tiered routing strategy that sends planning and review work to flagship models while delegating high-volume simple tasks to lighter tiers. It also covers cache usage and how to reproduce the cost model with controlled requests and linear regression.
LLM API Cost Measurement and Tiered Model Routing: A Practical Guide
Introduction: Why Billing Behavior Needs to Be Measured
When building applications on top of large language models, cost is often the most underestimated variable. Many developers focus only on model quality during prototyping, then discover during batch processing that quota consumption is far higher than expected. The root cause is that different inference tiers can have input, output, and cache-hit billing coefficients that differ by orders of magnitude, and these coefficients are not always publicly transparent.
This article is based on a real cost reverse-engineering exercise. It introduces a general method: how to use a small number of actual call records to fit token consumption rates for each tier, how to build a verifiable cost estimation model, and how to design a tiered model calling strategy based on the results. It does not target any specific vendor or product, and the conclusions can be transferred to any model service you are using.
1. How Large Is the Cost Gap? At Least One Order of Magnitude, and Up to Hundreds of Times in Extreme Cases
In a typical multi-tier model service, four roles can be roughly identified:
- Flagship tier: The strongest reasoning capability, suitable for planning, review, and complex decision-making, with the highest unit price.
- High-performance tier: Suitable for complex reasoning and code generation, costing roughly one-third to one-half of the flagship tier.
- Balanced tier: The main execution tier for routine conversation, rewriting, and tool calls, with a cost one order of magnitude lower again.
- Lightweight tier: Designed for high-volume simple tasks such as classification, extraction, and formatting, with the lowest cost.
The measured fitting results are shown below (example credit consumption per million tokens; these are personal reverse-engineered figures, not official pricing):
| Tier | Input | Output | Cache Hit |
|---|---|---|---|
| Flagship | ~80K | ~400K | — |
| High-performance | ~32K | ~112K | — |
| Balanced | ~4K | ~8K | ~80 |
| Lightweight | ~2K | ~2K | — |
Two sets of numbers deserve particular attention:
- The flagship tier’s output cost is about 200 times that of the lightweight tier. Output tokens are generally several times more expensive than input tokens, so “letting the most expensive model write the longest responses” is a typical waste pattern.
- For the balanced tier, the cost after a cache hit is only about 2% of normal input cost. For highly repetitive tasks, such as fixed system prompts and batch processing in the same format, cache hits are the most cost-effective optimization lever.
2. Reverse-Engineering Available Throughput from Quota
Assume a quota of 60,000 credits per 5 hours and 600,000 credits per week. Based on a typical traffic structure of 80% input and 20% output (ignoring cache benefits for now), the approximate token volume each tier can process per cycle is:
- Flagship tier: about 400K tokens
- High-performance tier: about 1.25M tokens
- Balanced tier: about 12.5M tokens
- Lightweight tier: about 30M tokens
In other words, within the same quota pool, choosing the right tier can yield dozens of times more throughput. This directly determines the application architecture: not every request should be sent to the strongest model. The strongest model’s capability should be spent only on stages where it is irreplaceable.
3. Tiered Calling Strategy: Expensive Models Think, Cheaper Models Execute
Based on the cost structure above, the following division of labor is recommended:
- Flagship tier: Responsible for task planning, solution review, and final quality control. Keep the number of calls low and require concise outputs.
- High-performance tier: Responsible for complex reasoning, key code generation, and difficult problem solving.
- Balanced tier: The main executor, handling high-frequency requests such as routine conversation, rewriting, and retrieval-augmented question answering.
- Lightweight tier: Handles batch simple tasks such as text classification, field extraction, format normalization, and initial filtering.
At the engineering level, a routing layer can implement automatic tier selection. First use the lightweight tier or rules to judge request complexity. Simple requests are handled locally, while complex requests are routed upward. On the output side, explicitly limit the maximum output length for the flagship tier to avoid cost blowouts caused by long responses. Example code:
def route(task):tier = classify_complexity(task) # Use the lightweight tier to judge complexity firstif tier == "planning":return call("flagship", task, max_output=500)if tier == "reasoning":return call("high", task)if tier == "batch_simple":return call("lite", task)return call("balanced", task)
Caching should also be used fully. Place stable system prompts and tool definitions in the request prefix so that repeated parts hit the cache. On the balanced tier, this can directly reduce input cost to about 2%.
4. How to Reproduce This Reverse-Engineering Method
The method itself is simple. The core is controlled variables plus linear fitting:
- Fix the prompt and construct multiple groups of requests where only the input length changes, and other groups where only the output length changes.
- Record the change in credit balance before and after each request.
- Use input volume and output volume as independent variables and credit consumption as the dependent variable, then perform multiple linear regression.
- Check the goodness of fit. In this exercise, the coefficient of determination was R² = 1.0, with residuals close to zero, indicating that consumption matched the actual records exactly and the reverse-engineered coefficients were credible.
Note that reverse-engineered results are not the same as official pricing. The provider’s billing rules may change at any time, so it is advisable to rerun the fitting script periodically and integrate cost monitoring alerts into daily operations to avoid service interruptions caused by quota exhaustion.
Conclusion
Cost optimization for LLM applications is essentially a resource scheduling problem: first measure the real price of each tier, then spend compute where it matters most. Build a reproducible cost model, design tiered routing, and make good use of caching. Once these three things are done, the same budget can support dozens of times the processing volume.
