LLM Inference Cost: Benchmarking Real Consumption and Tiered Routing
This article shows how to reverse-engineer the actual per-token cost of different LLM tiers using linear regression on real usage logs, rather than relying on published price sheets. It presents measured consumption rates across four model tiers, translates a fixed credit quota into throughput per tier, and explains how to build a tiered routing strategy where expensive models handle reasoning and cheaper models handle execution. It also covers prompt caching, context engineering, and pre-launch validation steps to keep a cost model aligned with real billing.
1. Why “Expensive” Is Not Always Actually Expensive
When building an intelligent coding assistant, a document understanding pipeline, or a multi-turn chat application, teams often run into the same confusion: the same request can produce bills that differ by an order of magnitude just by switching models. Most people respond by checking the price sheet, but price sheets usually only list a per-million-token rate. Real bills are also affected by the input/output ratio, cache hit rate, context length distribution, and retry counts, which is why budgets and actual spending diverge so badly.
A more reliable approach is reverse engineering: take real usage records over a period of time (request counts, input and output token counts, credit or quota consumption) and fit them to derive the actual consumption rate of each model. When the sample is clean enough, the fit can be excellent and the residuals close to zero, which shows that the consumption model is linear and predictable.
2. Method: Deriving Unit Consumption Rates with Linear Regression
Let C be the credit consumption of a model within a time window, X_in the total input tokens, X_out the total output tokens, and X_cache the cache-hit tokens. You can then build a linear model:
C = a * X_in + b * X_out + c * X_cache + d
Here a, b, and c are the unit consumption rates to solve for, and d is the intercept (theoretically close to 0, and useful for verifying whether billing is purely linear). Running a least-squares fit over multiple observations with different workloads yields the coefficients.
The magnitudes derived from measurement (personal samples, not an official price sheet) are roughly:
- Flagship reasoning: input about 80,000 per million tokens, output about 400,000 per million tokens;
- Balanced reasoning: input about 32,000 per million tokens, output about 112,000 per million tokens;
- Fast execution: input about 4,000 per million tokens, output about 8,000 per million tokens, with cache hits as low as 80 per million tokens;
- Lightweight batch: 2,000 per million tokens for both input and output.
Two key conclusions: the output rate of the flagship model can be about 200 times that of the lightweight model; and for the fast execution tier, once a cache hit occurs, input cost drops to only about 2% of the normal value. This shows that the first lever for cost optimization is not “switch to a cheaper model” but “raise the cache hit rate + control output length.”
3. Quota Translation: How Much Work Each Model Can Do in 5 Hours
Take a quota of 60,000 credits per 5 hours and 600,000 credits per week. Assuming input accounts for 80%, output for 20%, and ignoring cache for now, you can convert this into the token volume each tier supports:
| Model tier | Approx. tokens processable per 5 hours |
|---|---|
| Flagship reasoning | ~417,000 |
| Balanced reasoning | ~1.25 million |
| Fast execution | ~12.5 million |
| Lightweight batch | ~30 million |
With the same quota, throughput between tiers differs by nearly two orders of magnitude. This explains a common phenomenon: the team is not “out of quota,” but is spending the high-rate tier on steps that do not actually need it.
4. Tiered Routing: Expensive Models Think, Cheap Models Do
Based on the consumption rates above, tasks can be layered by “reasoning depth required”:
- Flagship tier: requirement clarification, solution design, final code review, and risk assessment. Characterized by long input, precise output, and few calls.
- Balanced tier: complex logical reasoning, tricky defect localization, and cross-module refactoring suggestions.
- Fast tier: the main execution workhorse, such as routine code generation, unit test completion, and log summarization, where cache reuse yields the greatest benefit.
- Lightweight tier: batch simple tasks such as format conversion, field extraction, batch commenting, and classification/tagging.
Sample routing pseudocode:
def route(task):if task.needs_arch_decision or task.is_final_review:return "flagship"if task.complexity >= 0.7:return "balanced"if task.batch and task.simple:return "lite"return "fast"
The accompanying engineering constraints matter just as much: set a context budget cap for each tier; place stable system prompts and project conventions at the front to improve prefix cache reuse; and set a hard cap on output length, since the output rate is usually several times the input rate.
5. Cost Engineering for Caching and Context
A cache hit pushes the fast tier’s input cost down to 2%, but only if the request prefix stays stable. Practical points include: put invariant content (tool descriptions, coding standards, directory structure) at the very front of the prompt; avoid inserting volatile content such as timestamps or random IDs into the session; and for long documents, use a reference-style context of “write once, reuse many times” instead of pasting the same content every turn. If you use cloud object storage to hold intermediate artifacts, a message queue to decouple tasks, and logging and monitoring/alerting services to observe call volume, you can further turn repeated computation into compute-once, reference-many.
6. Pre-Launch Validation and Risks
Before going live, three validation steps are recommended: first, regress on at least three sets of different workload data and check whether the intercept is close to zero; second, hold out one day of data for backtesting and compare the deviation between predicted and actual consumption; third, configure quotas and fallback policies for each tier so that requests automatically drop to a lower tier when the limit is exceeded.
Note that all consumption rates above are personal reverse-engineered measurements, not an official price sheet; billing rules, caching policies, and quota policies can change at any time. Production systems should make unit costs and routing thresholds configuration items rather than hard-coded values, and periodically re-fit with new data to keep the cost model consistent with real bills.
