LLM API Cost Breakdown and Tiered Model Routing in Practice
This article breaks down why a cheaper per-token price does not always produce a cheaper bill, and shows how to measure it. It explains how input, output, and cache-hit tokens each carry a different consumption rate, how to reverse-engineer those rates from real usage records with least-squares fitting, and what relative rates look like across four model tiers. It then converts a fixed credit quota into processable token volume and applies the result to a tiered routing strategy, where high-cost models handle planning and review while low-cost models handle high-frequency execution. A practical cost-optimization checklist is included. All figures are relative magnitudes for internal capacity planning only.
1. Background: Why a Lower Unit Price Does Not Mean a Lower Bill
When building an AI coding assistant, an automated agent, or an enterprise knowledge Q&A system, teams most often run into the same confusion: they picked a tier with a lower unit price, yet the monthly quota runs out first. The reason is that LLM billing is not driven by a single price. It is determined by three quantities — input tokens, output tokens, and cache-hit tokens — each multiplied by a different consumption rate per tier. Any judgment based only on “price per million tokens” will be off by orders of magnitude under real workloads.
More importantly, real workloads tend to underestimate the output share. In code generation, long-form reasoning, and structured extraction, the output length can be several times the input length, and the consumption rate on the output side is usually much higher than on the input side. So the first step in cost governance is not to negotiate a lower price, but to establish a measurable accounting basis.
2. Method: Reverse-Engineering Consumption Rates from Real Usage Records
When no official price list is available to rely on, you can fit the credit consumption rate of each tier by regression. The core idea: treat the input volume, output volume, and cache-hit volume of each session as independent variables, and the credits deducted for that session as the dependent variable, then solve for the coefficients with least squares.
Illustrative code (it only expresses the modeling idea and does not involve any specific API):
import numpy as np# Columns of X: input tokens, output tokens, cache-hit tokens, constant termX = np.array([[80_000, 40_000, 0, 1],[150_000, 60_000, 120_000, 1],[30_000, 20_000, 0, 1],], dtype=float)y = np.array([12.0, 15.5, 3.2]) # credits actually deductedcoef, residual, rank, _ = np.linalg.lstsq(X, y, rcond=None)pred = X @ coefr2 = 1 - ((y - pred) ** 2).sum() / ((y - y.mean()) ** 2).sum()print(coef, r2)
When the sampling covers enough sessions and the input-to-output ratios differ widely enough, the goodness of fit can approach 1 and the residuals approach 0, which indicates that the model form matches the actual billing rules closely. Three things need attention in engineering practice. First, the sample must include input-heavy, output-heavy, and mixed sessions to avoid collinearity. Second, cache-hit volume must be recorded separately; otherwise that term gets absorbed into the input coefficient and distorts later budget forecasting. Third, the fitted result should only serve as an internal baseline for capacity planning — the rules may change with platform policy, so it needs to be recomputed periodically with fresh data.
3. Findings: Orders-of-Magnitude Differences Between Tiers
Fitting the actual usage records with the method above yields a representative set of relative consumption rates (expressed as credits per million tokens; the values are illustrative relative magnitudes):
| Tier | Input | Output | Cache hit |
|---|---|---|---|
| Flagship reasoning | ~80K | ~400K | No significant discount |
| Balanced reasoning | ~32K | ~112K | Partial discount |
| Fast execution | ~4K | ~8K | ~80 |
| Lightweight batch | ~2K | ~2K | ~2K |
Two conclusions are worth emphasizing. First, the output cost of the flagship tier can be about 200 times that of the lightweight tier, which means handing batch summarization or format conversion to the flagship tier is the main source of wasted quota. Second, for the fast execution tier, the cost after a cache hit is only about 2% of the normal input cost. For agent loops that repeatedly read the same codebase or the same spec document, the cache hit rate directly determines the order of magnitude of the bill.
4. Conversion: Turning a Credit Quota into Processable Token Volume
Let the quota be 60K credits per 5 hours and 600K credits per week. Assuming a workload mix of 80% input and 20% output, and ignoring cache benefits for now, the total tokens a unit of quota can support is approximately:
processableTokens = quota / (0.8 * inputRate + 0.2 * outputRate)
Plugging in the magnitudes from the table above, the approximate throughput per 5-hour window is about 417K tokens for the flagship tier, about 1.25M for the balanced tier, about 12.5M for the fast execution tier, and about 30M for the lightweight tier — a span of nearly two orders of magnitude across the four tiers. The value of this conversion is that it turns “the quota feels insufficient” into concrete variables you can optimize: either reduce the output share, raise the cache hit rate, or move the task to a lower tier.
5. Tiered Routing: Expensive Models Think, Cheap Models Do
Given the cost gradient, the sensible engineering strategy is to tier by cognitive complexity rather than by business module.
- Flagship reasoning: task decomposition, solution planning, architecture trade-offs, and final code review. These tasks have long inputs, short outputs, and low call frequency, so the value per unit of output is the highest.
- Balanced reasoning: complex logical reasoning, hard defect localization, and cross-file refactoring plans.
- Fast execution: mainstream coding, unit test completion, and documentation generation — high-frequency execution tasks that reuse project context through caching.
- Lightweight batch: batch formatting, log categorization, simple classification, and template filling.
The routing layer can be implemented with a dual channel of rules plus confidence:
def route(task):if task.risk == "high" or task.needs_plan:return "flagship"if task.complexity >= 3:return "balanced"if task.batch and task.repeat_context:return "fast_cached"return "lite"
In practice, it is advisable to reserve 5%–10% of the quota for the flagship tier, so that planning and review do not get downgraded because the quota is exhausted, which would raise the overall rework cost.
6. Cost Optimization Checklist
- Keep the context prefix stable: fix the system prompt, project conventions, and dependency list at the very front to maximize cache hits.
- Compress retrieved snippets: rerank first, then feed them to the model, instead of stuffing an entire document into the input.
- Constrain the output structure: use schema constraints to reduce wasted generation and repeated retries.
- Set up budget guardrails: throttle on both a per-session and a per-day basis, and downgrade to a lower tier automatically once a threshold is exceeded.
- Instrument the full pipeline: log the input/output/cache-hit triple and recompute the consumption-rate baseline weekly.
7. Conclusion
The essence of the cost difference is a difference in tier positioning, not in quality. Once you establish a measurable accounting basis, fit consumption rates from real data, and then apply tiered routing by cognitive complexity together with cache reuse, you can raise effective output by an order of magnitude under a fixed quota. One caveat: the numbers above are relative magnitudes reverse-engineered from personal measurements, intended only for internal capacity planning. The actual rules are governed by the latest documentation of the platform in use, and the baseline should be recalibrated continuously as the workload changes.
