LLM Inference Cost Evaluation: A Practical Look at Token Efficiency
Choosing a large language model based only on the price per million tokens is a common and costly mistake. This article explains why a lower unit price can still produce a higher bill, using a controlled test across three model tiers to show how total token consumption, retries, and task completion rate turn unit price into actual spend. It also outlines a reusable four-step evaluation method, sample routing logic, and engineering optimizations such as context governance, output constraints, and caching. The goal is to help readers evaluate inference cost by effective cost per completed task rather than list price.
1. The Problem: Why a Lower Unit Price Can Cost More
When selecting a large language model, teams most often make one mistake: treating the price per million tokens as the only decision criterion. The real bill is determined by four variables working together: the total tokens consumed to complete a task, the pricing structure for input versus output, the extra consumption caused by retries and failures, and whether the task was actually completed. Unit price affects only the second of these.
An abstract cost model looks like this:
Cost per task = (input tokens × input price + output tokens × output price) × retry factorEnd-to-end value = task completion / end-to-end latency
The retry factor is often overlooked. If a model stops generating too early and fails to complete the task, the business side usually needs one or more additional rounds of interaction to converge, so the actual factor can be significantly greater than 1. Any comparison must therefore return to the premise of “completing the same task”; otherwise the comparison does not hold.
2. Test Setup and What Was Measured
This test used a routine task of moderate difficulty. Under the same prompt, the same input context, and the same acceptance criteria, the same set of tasks was run against three differently positioned model tiers (referred to below as Tier A, Tier B, and Tier C, with prices increasing in that order). Three metrics were recorded: total token consumption, actual billed amount, and end-to-end latency.
It is worth stressing that results like these only reflect performance under a specific task distribution and are not universally applicable. Token efficiency is essentially “a model’s ability to advance a task per unit of tokens,” and it varies dramatically by task type (long-form writing, code modification, structured extraction, multi-turn tool calls). The right approach is to treat the test as a method demonstration, not as a conclusion to copy.
The observed relative relationships are shown below (values are normalized for readability):
| Tier | Relative unit price | Relative total cost | End-to-end latency |
|---|---|---|---|
| Tier C | 4× | ~2× | ~27 minutes |
| Tier B | 2× | ~1× (baseline) | ~30 minutes |
| Tier A | 1× (baseline) | ~1× | ~23 minutes |
Two points stand out. First, Tier B’s unit price is double Tier A’s, yet the cost of completing the same task is almost identical, which means lower token consumption offset the higher unit price. Second, Tier C’s unit price is four times Tier B’s, but the actual cost is only about twice as high, with shorter latency; this shows that the higher-priced tier compressed the cost increase into a sublinear range through fewer round trips and less wasted output.
3. Interpreting the Results: How Token Efficiency Becomes a Cost Advantage
Converting the table above into “cost per unit of effective output” makes it more intuitive. Let the task completion rate be q; then the effective cost is total cost / q. If a lower-tier model stops early and q is clearly less than 1, its seemingly 1× cost is amplified under the effective measure and can even overtake the higher tier. This explains why, in real business settings, a cheaper model can end up with a higher total bill.
Latency is also affected by token efficiency. End-to-end time is determined jointly by time to first token, output rate, total output length, and the number of interaction rounds. A more verbose model is not only slower but also more likely to trigger context bloat in long tasks, further driving up input tokens in subsequent rounds.
It is worth noting that higher tiers can sometimes be slower. This is usually not model degradation, but rather the lower tier converging and finishing early, trading shorter output for lower latency at the cost of incomplete work. When evaluating, “fast” must be tied to “finished”; otherwise the wrong conclusion follows.
4. A Reusable Cost Evaluation Method
It is recommended to fix the selection process into four steps:
- Build a task set: extract 30–100 representative requests from real business, covering both high-frequency and long-tail cases, and annotate acceptance criteria.
- Unify the measurement basis: fix the prompt, sampling parameters such as temperature, context length, and maximum output limit to avoid variable contamination.
- Record two metrics: log both the billed amount and the completion rate, compute
effective cost = cost / completion, and track P50/P95 latency. - Layered routing: tier tasks by difficulty, send simple requests to the lower tier and complex requests to the higher tier, using rules or a small model for upfront classification.
Illustrative routing logic:
def route(task):# Coarse tiering based on empirical features; thresholds must be derived by regression on real dataif task.estimated_difficulty < 0.4 and task.context_tokens < 4000:return "tier_low"if task.estimated_difficulty < 0.75:return "tier_mid"return "tier_high"
5. Engineering Optimizations on the Side
Model tier is only one part of the cost equation; engineering measures often deliver larger gains:
- Context governance: rerank after retrieval and inject only necessary fragments to compress input tokens; use summary-style memory for long conversations.
- Output constraints: use structured formats and explicit word or field requirements to suppress verbose output and directly reduce output tokens.
- Cache reuse: build a semantic cache for stable prefixes and high-frequency Q&A; a cache hit is not billed.
- Failure fallback: set completion checks and a cap on automatic retries to avoid endlessly adding rounds.
- Observability: instrument tokens and latency by business dimension in logging, monitoring, and alerting to form a cost dashboard.
When deploying in the cloud, you can combine a container platform to host inference services, object storage to hold datasets and results, a message queue to smooth peaks, and a logging and monitoring system for attribution, turning cost optimization from one-off tuning into continuous operations.
6. Conclusion and Caveats
Unit price is a quote; cost is the bill. What truly determines cost is the total tokens required to complete the same task and the completion rate, which together compress the actual increase of the higher-priced tier into a sublinear range. The practical recommendation is: first build a task set with acceptance criteria, then use effective cost and P95 latency as the primary metrics for layered routing, and finally use context governance, output constraints, and caching to push costs down further. It should also be clear that numbers from any single small-scale test hold only within the corresponding task distribution; production decisions must be based on regression against your own data.
