LLM Token Cost Benchmarking and Tiered Model Routing in Practice
This article shows how to reverse-engineer per-token costs across multiple LLM services by treating billing as a linear model, then uses the resulting price tiers to build a tiered routing strategy. You will find a least-squares fitting method with validation code, measured cost gaps across four model tiers, why output tokens dominate spend, practical output compression and context caching techniques, observability metrics, and budget guardrails. Note that all figures are order-of-magnitude estimates from personal measurements, not official pricing.
1. Background: Why Bills That “Feel About the Same” Can Differ by Orders of Magnitude
Once you connect several large model services at the same time, the most common question is not “which model is smarter” but “why is my credit balance dropping so fast this week.” Most platforms only show a single aggregate curve on the billing dashboard. You see the balance fall, but not whether the drop came from input, output, or cache hits. When any one of the input/output ratio, context length, or retry count changes, total consumption swings sharply, so judging cost by intuition is almost guaranteed to be wrong.
The core idea of this article is therefore to treat billing as a linear model, use real usage records to back out unit costs, and then build task tiers on top of those results. The value is that cost stops being an opaque deduction and becomes a computable, predictable, optimizable engineering metric.
2. Method: Backing Out Unit Token Costs with Linear Fitting
In general terms, the billing structure of mainstream large model services can be abstracted into three items: input tokens, output tokens, and cache-hit tokens. Let the credit consumption of one session be C:
C = a * T_in + b * T_out + c * T_cache + da: input unit price (credits per million tokens)b: output unit price (credits per million tokens)c: cache-hit unit price (credits per million tokens)d: fixed overhead or minimum billing unit (usually 0)
With three or more mutually linearly independent samples (that is, sessions with different input/output ratios), you can solve for a, b, and c using least squares. Three practical points matter:
- Make the samples differ substantially. If every session is 80% input and 20% output, the equations are highly correlated and the solution will be unstable. Deliberately construct both long-input/short-output and short-input/long-output sessions.
- Record data at session granularity. Log timestamps, input and output token counts, and credit deltas by hand, and avoid merging across sessions.
- Validate with residuals. After fitting, compute R² and the residuals. If the residuals are near zero and R² is close to 1, billing really is linear and the back-calculation is trustworthy. If the residuals are large, nonlinear factors such as tiered pricing, a minimum billing unit, or credit expiry are in play, and you need piecewise modeling.
Sample validation code:
import numpy as np# Each row: [input tokens, output tokens, cache-hit tokens, actual credits]X = np.array([[820_000, 180_000, 0, 420],[120_000, 680_000, 0, 610],[900_000, 100_000, 700_000, 260],], dtype=float)y = np.array([420, 610, 260], dtype=float)coef, *_ = np.linalg.lstsq(X, y, rcond=None)pred = X @ coefss_res = ((y - pred) ** 2).sum()ss_tot = ((y - y.mean()) ** 2).sum()print("input/output/cache unit price:", coef)print("R^2 =", 1 - ss_res / ss_tot)
3. Measured Results: Cost Gaps Can Be Extreme
Under a normalized budget (60,000 credits per 5 hours, 600,000 credits per week, assuming 80% input plus 20% output and ignoring cache for now), the token volume that four typical model tiers can carry looks roughly like this:
| Tier | Input unit price (order of magnitude) | Output unit price (order of magnitude) | Tokens per 5 hours |
|---|---|---|---|
| Flagship reasoning | ~80,000 per million | ~400,000 per million | ~417,000 |
| Balanced reasoning | ~32,000 per million | ~112,000 per million | ~1,250,000 |
| High throughput | ~4,000 per million | ~8,000 per million | ~12,500,000 |
| Lightweight | ~2,000 per million | ~2,000 per million | ~30,000,000 |
Two structural facts are worth remembering:
- The flagship tier’s output unit price is about 200x that of the lightweight tier. Having a flagship model write a thousand more words is simply not the same deal as having a lightweight model write a thousand more words.
- On the high-throughput tier, with a cache hit, cost can drop to around 2% of the normal input unit price. In other words, repeated long contexts that hit the cache have almost negligible marginal cost.
To be clear: the numbers above are order-of-magnitude references back-calculated from personal measurements, not any official price list. The rules can change at any time, so before putting this into production, refit against the real billing of your own account.
4. Why Output Costs More Than Input: A Commonly Overlooked Cost Amplifier
From a billing-design standpoint, input tokens can be processed in parallel, while output tokens are generated autoregressively one token at a time, so compute utilization is inherently lower. Output unit prices are therefore generally higher than input unit prices, and the gap is especially large on the flagship tier. This leads to a counterintuitive engineering conclusion: the first principle of cost control is not “send fewer requests” but “generate less content.”
Actionable compression techniques include: ask the model to output only a structured patch instead of a full file; split long-form writing into an outline plus sections; cache reusable templates; and turn verbose “explain your reasoning” output into bullet points. These changes can often push the output share from 20% down below 10%, which is roughly equivalent to halving overall cost.
5. Tiered Routing: Expensive Models Think, Cheap Models Do
Given the unit price tiers above, here is a recommended four-tier task allocation strategy:
- Flagship reasoning: requirements clarification, solution design, architecture tradeoffs, and final code review. These tasks have long input and short output, which lands exactly in the range where the flagship tier is relatively insensitive to cost.
- Balanced reasoning: complex logical reasoning, tricky defect localization, and cross-module refactoring plans.
- High throughput: the main workhorse for bulk code generation, test completion, and log analysis. Combined with cache hits, repeated calls with long context are extremely cheap.
- Lightweight: bulk simple tasks such as formatting, renaming, comment generation, and classification/tagging.
A minimal scheduler implementation can be very plain:
def route(task):if task.kind in {"plan", "review"}:return "flagship"if task.kind in {"reason", "refactor"}:return "balanced"if task.kind in {"generate", "test"}:return "throughput"return "lite"
A more advanced approach turns routing into a closed loop with feedback: record the actual credit consumption and rework rate of each task category, refit unit prices every week, and adjust thresholds dynamically. When a task category’s rework rate exceeds a set ceiling, automatically bump it up one tier, trading cost for quality; otherwise move it down, trading spare quality margin for cost.
6. Caching and Context Management
The cache-hit unit price is only a tiny fraction of the normal input price, so context management is the first lever in high-throughput scenarios. Common practices include: put stable system prompts, project conventions, and interface contracts at the very front of the context and keep them byte-for-byte identical; put volatile user input at the end; and avoid pointlessly changing the prefix mid-session, or the entire cache is invalidated. In engineering terms, you can add a version number to prompt templates: reuse the cache while the version is unchanged, and deliberately accept one cold-start cost when the version changes.
7. Observability and Budget Guardrails
No measurement, no optimization. Instrument at least three metrics: credit cost per task, input/output token ratio, and cache hit rate. Then add budget guardrails, for example a per-session credit cap, a daily total alert, and automatic downgrade to the lightweight tier when the limit is exceeded. Sample logic:
if session.cost > session.limit * 0.8:alert("approaching budget limit")if session.cost > session.limit:model = "lite"
8. Common Pitfalls
- Looking only at total credits and not the structure, which sends optimization in the wrong direction.
- Fitting with samples that all share one input/output ratio, which yields an unstable solution.
- Ignoring billing for retries and failed requests, which underestimates real cost.
- Using a flagship model for bulk execution, which inflates cost by one to two orders of magnitude.
- Changing the prompt prefix frequently, which drives the cache hit rate toward zero over the long run.
9. Conclusion
The essence of the cost difference is not “expensive versus cheap” but that different tiers are priced structurally differently across the three dimensions of input, output, and cache. First use linear fitting to reduce the bill to unit prices, then route tasks in tiers on the principle of “expensive models think, cheap models do,” and combine that with context and cache management, budget guardrails, and a weekly refitting loop. That turns uncontrollable deductions into a predictable engineering budget. One more reminder: the numbers here are order-of-magnitude references back-calculated from personal measurements, not official pricing. Use your own billing as the source of truth and recalibrate regularly.
