Measuring LLM Inference Costs and Tiered Routing in Practice
This article shows how to turn unpredictable LLM billing into a measurable model by fitting credit consumption against input tokens, output tokens, and cache-hit tokens. It shares reverse-engineered consumption rates across four model tiers, compares real throughput differences, and outlines a four-layer routing strategy, caching practices, and operational safeguards for keeping inference costs under control. Note that all figures are personal estimates, not official pricing.
1. Why “It Feels Expensive” Cannot Guide Engineering Decisions
When integrating LLM capabilities into a business system, the hardest problem is usually not output quality but unpredictable cost. The same feature can produce bills that differ by an order of magnitude simply because the prompt is written differently or the context is longer. Choosing a model based on a vague sense that “this one is more expensive” almost always leads to budget overruns.
The engineering-friendly approach is to abstract billing into a measurable model: credit consumption over a given period is a linear combination of three variables: input tokens, output tokens, and cache-hit tokens. With a handful of real usage records, you can solve for the consumption coefficient of each variable, turning a fuzzy impression of price into parameters you can plug into a calculation.
This article follows that approach. All numbers come from personal measurements and reverse engineering; they do not represent any official pricing, and the rules may change at any time.
2. Method: Reverse-Engineering Consumption Rates with Linear Fitting
Let credit consumption in a period be C, and the numbers of input, output, and cache-hit tokens be x1, x2, and x3:
C = a·x1 + b·x2 + c·x3 + d
Here a, b, and c are the consumption rates per million tokens to be solved for, and d is a constant term that absorbs statistical error and the minimum billing unit. Collect four or more linearly independent real records, and you can solve with least squares.
Fitted results from personal reverse engineering (not official data):
| Model tier | Input / 1M | Output / 1M | Cache hit / 1M |
|---|---|---|---|
| Flagship reasoning | ~80,000 | ~400,000 | Not measured separately |
| Balanced | ~32,000 | ~112,000 | Not measured separately |
| Fast | ~4,000 | ~8,000 | ~80 |
| Lite | ~2,000 | ~2,000 | Not measured separately |
The fit has R² = 1.0 with residuals near zero, matching actual bill deductions almost exactly. This shows two things: billing is genuinely linear, and the sampling range was dispersed enough that the parameters were not distorted by collinearity.
Engineering takeaway: as long as you can export per-call token statistics and credit changes, you can build this measurement yourself instead of waiting for any official explanation.
3. The Real Magnitude of Cost Differences
Taking ratios from the table above, the conclusion is more extreme than intuition suggests:
- Flagship output cost is roughly 200x that of the lite tier;
- For the fast tier with a cache hit, input cost is only 2% of normal input cost;
- The balanced tier sits in the middle, with input cost about 8x that of the fast tier.
Converting to usable credits, at a pace of 60,000 credits per 5 hours and 600,000 credits per week, assuming 80% input, 20% output, and no cache for now:
| Model tier | Tokens processable in 5 hours |
|---|---|
| Flagship reasoning | ~417,000 |
| Balanced | ~1.25M |
| Fast | ~12.5M |
| Lite | ~30M |
That is roughly a 72x spread from end to end. If every request goes to the flagship tier, your effective throughput shrinks to a fraction of its potential, even though most tasks do not need that much capability.
4. Tiered Routing: Let Expensive Models Only Do the “Thinking”
The core of cost optimization is not cutting prices but matching tasks to tiers. A recommended four-layer structure:
- Flagship reasoning: requirement breakdown, solution design, final code review, and root-cause analysis of hard issues;
- Balanced: complex logical reasoning, cross-file refactoring, and edge-case analysis;
- Fast: mainstream code generation, routine Q&A, and unit test completion;
- Lite: batch formatting, comment generation, log classification, and other simple repetitive tasks.
Illustrative routing logic:
def route(task):if task.needs_architecture or task.is_final_review:return "flagship"if task.needs_deep_reasoning:return "balanced"if task.is_batch_simple:return "lite"return "fast"
Three supporting disciplines: set a context limit for each task type to avoid stuffing an entire repository into the prompt; place stable system instructions and specification notes at the front to maximize cache hits; and log the tier, token distribution, and credit change for every call to continuously recalibrate the coefficients.
5. Caching: The Underrated Cost Lever
Cache-hit pricing is typically only a few percent of normal input pricing, making it the highest-return optimization point. Practical tips: keep the prompt prefix stable, put volatile content at the end, avoid inserting timestamps or other random strings into long contexts, and build fixed templates for high-frequency repeated Q&A. In batch scenarios, raising the hit rate from 0 to over 50% often delivers more savings than switching models.
6. Implementation Advice and Risk Notes
If platform-side support is needed, combine general cloud capabilities: use object storage to hold prompt and sample sets, a message queue for task prioritization and peak shaving, a container platform to host the inference gateway, and logging plus monitoring and alerting for usage and cost dashboards.
It must be emphasized that all coefficients and throughput figures here are personal measurements and reverse engineering, not any official price list; vendor rules, caching strategies, and minimum billing units can all change. Make the measurement script and dashboard a routine artifact, re-fit after every rule change, and adjust routing thresholds accordingly.
