LLM Token Cost Measurement and Tiered Model Routing
Learn how to estimate LLM token prices from actual usage records, validate a linear billing model, and translate credit budgets into processing capacity. This article examines measured cost differences across model tiers and outlines practical routing, caching, and monitoring strategies for keeping inference costs predictable.
1. Why Token Cost Estimates Miss the Mark
Before putting large language models into production, teams usually focus on two questions: Is the quality good enough, and can the application run reliably? Once usage-based billing begins, a third question emerges: Where is the money going?
Costs often spiral not because unit prices are high, but because teams lack a quantitative understanding of the billing structure. Three mistakes are especially common:
- Estimating costs by request count alone. A single request can contain anything from a few hundred tokens to hundreds of thousands. The cost difference can span orders of magnitude.
- Ignoring different input and output prices. Most model services charge substantially more for output tokens than input tokens. Agent applications often mix long-input, short-output requests with short-input, long-output requests.
- Overlooking caching. When requests repeatedly carry the same system prompt or repository context, cache hits can directly change the effective input cost.
The first step in cost management is therefore not to cut requirements. It is to formalize the billing rules and validate them against real usage data.
2. Turn Billing Rules into a Model You Can Fit
For many usage-based LLM services, the credits consumed by a call can be represented as the sum of three components:
Cost = Pin × Tin + Pout × Tout + Pcache × Tcache
Here, Tin, Tout, and Tcache represent uncached input tokens, output tokens, and cached input tokens. Each P* is the corresponding unit price.
Providers may quote prices in credits per thousand or million tokens. When applying the formula, token counts and price units must use the same scale.
This model is linear, which makes it useful for measurement: with enough real call records, you can infer unit prices for each model tier rather than relying solely on a published price list.
The inputs are the three token counts for each call. The target is the number of credits actually deducted:
import numpy as np# rows: [uncached input tokens, output tokens, cached input tokens]X = np.array([[12000, 800, 30000],[45000, 1500, 120000],[8000, 400, 0],# ... additional real call samples], dtype=float)y = np.array([186.4, 592.0, 64.0]) # Actual credits deductedcoef, *_ = np.linalg.lstsq(X, y, rcond=None) # Infer unit pricespred = X @ coefss_res = ((y - pred) ** 2).sum()ss_tot = ((y - y.mean()) ** 2).sum()r2 = 1 - ss_res / ss_totprint(coef, r2, np.abs(y - pred).max())
Evaluate the fit using two metrics, not just one:
- Coefficient of determination, R²: A value close to 1 indicates that the model explains most of the observed variation.
- Maximum absolute residual: A high R² with large residuals can indicate missing billing components, such as cache writes, long-context pricing bands, or failed retries.
In production, make this an offline script that runs once per billing cycle. Store the resulting prices in a centralized configuration service rather than hard-coding them into application logic.
3. Measured Cost Differences Across Model Tiers
Applying this method to several model tiers on one platform produced a striking observation: output token prices across tiers can differ by two orders of magnitude.
The following figures illustrate the approximate scale inferred from personal measurements. They are not official prices.
| Model tier | Input credits per million tokens | Output credits per million tokens | Cached input credits per million tokens |
|---|---|---|---|
| Flagship reasoning | ~80,000 | ~400,000 | Not separately priced |
| Balanced | ~32,000 | ~112,000 | Not separately priced |
| Fast | ~4,000 | ~8,000 | ~80 |
| Lightweight | ~2,000 | ~2,000 | ~2,000 |
Two findings matter most:
- Flagship output costs about 200 times as much as lightweight output. Assigning bulk generation to the flagship tier can mean paying 200 times more for reasoning depth the task does not require.
- Cached input on the fast tier costs about 2% of its normal input price. For agents that repeatedly carry the same system prompt, code context, or long document, caching can offer more leverage than switching models.
These figures were inferred from billing records and may change as platform rules change. Use them as order-of-magnitude guidance for architecture decisions, not as guaranteed inputs to financial forecasts.
4. Translate Credit Budgets into Token Capacity
Once unit prices are known, you can answer a practical product question: How much work can a credit allocation support?
Assume a budget of 60,000 credits per five-hour window and 600,000 credits per week, with a workload consisting of 80% input tokens and 20% output tokens. Ignoring caching benefits, the approximate capacity per five-hour window is:
| Model tier | Approximate total tokens per five-hour window |
|---|---|
| Flagship reasoning | 417,000 |
| Balanced | 1.25 million |
| Fast | 12.5 million |
| Lightweight | 30 million |
The value of this comparison is that it turns a vague distinction between “expensive” and “cheap” into measurable processing capacity.
The roughly 70-fold capacity gap between the flagship and lightweight tiers helps determine which tasks should run in small batches and which can run across an entire workload.
These estimates depend heavily on the input/output mix. Increasing the output share from 20% to 50% substantially reduces flagship capacity. This is why output-heavy tasks should be prioritized for lower-cost tiers.
5. Tiered Routing: Expensive Models Plan, Cheaper Models Execute
The architectural principle is simple: allocate deep reasoning as a scarce resource.
A four-tier division of responsibilities can look like this:
- Flagship — planning and final review. Task decomposition, approach selection, code review, and difficult root-cause analysis. Calls should be relatively infrequent but high-value.
- Balanced — complex reasoning. Cross-file refactoring, algorithm design, and intermediate tasks requiring multiple reasoning steps.
- Fast — primary execution. Most code generation, unit test completion, documentation, and routine question answering.
- Lightweight — simple batch processing. Format conversion, field extraction, classification, labeling, and bulk summarization.
The routing layer can remain small:
def route(task):if task.kind in ("plan", "review", "root_cause"):return "flagship"if task.requires_multi_step_reasoning:return "balanced"if task.batch_size > 100 and task.output_tokens < 512:return "lite"return "fast"
Three operational capabilities matter more than the routing logic itself:
- Fallback: If the flagship tier is rate-limited or exceeds its budget, automatically fall back to the balanced tier and mark the downgrade instead of failing outright.
- Observability: Log the model tier, token-count triple, actual credit deduction, and cache-hit status for every call. Set monitoring thresholds for the rate of credit consumption.
- Traceability: Include the tier-selection decision in distributed traces so that, when something goes wrong, the team can explain why an expensive model was selected.
6. Caching: An Underestimated Cost Lever
For long-context workloads, cache hit rate can affect the bill more than changing models. Practical optimizations include:
- Keep prefixes stable. Place system prompts, tool definitions, and persistent context at the beginning. Avoid dynamic changes that shift the prefix and invalidate cache reuse.
- Move timestamps and random values out of the prefix. Put the current time and random IDs near the end of the prompt instead.
- Reuse stable segments. Split large documents into stable blocks and reuse cached blocks where supported, rather than resending the entire document each time.
- Monitor cache hit rate. Treat it as a first-class monitoring metric. A sudden decline often indicates a prompt-template change.
7. Limits and Trade-offs
- All prices and capacity figures in this article are approximate values inferred from personal measurements, not an official price list. Platform rules, context-length pricing bands, and caching policies can change.
- Linear fitting assumes that billing is approximately linear. Tiered pricing, minimum charges, or charges for failed calls require piecewise regression or additional features.
- Tiered routing trades some “best possible model on every task” quality for predictable capacity. Whether that trade-off is worthwhile depends on the business’s actual balance between cost and quality.
The takeaway: Fit billing rules into a computable model, validate it against real records using both R² and residuals, and use tiered routing to reserve expensive reasoning for tasks that genuinely need it. Let higher-cost models handle difficult decisions and lower-cost models handle repetitive execution.
