LLM Inference Cost Evaluation: Why Unit Price Is Not the Whole Bill
This article explains why comparing per-million-token prices alone leads to misleading conclusions about LLM inference costs. It breaks down the real cost formula, shows how output throughput affects concurrency and hardware amortization, and demonstrates how input/output token ratios change the effective blended price. It also covers engineering cost levers such as prefix caching, batch APIs, streaming, and output length limits, plus how first-pass success rate should be the denominator of cost. A practical evaluation and routing workflow is included to help developers make decisions based on their own traffic profile rather than headline pricing.
1. The Core Problem: Unit Price Is Not the Bill
When evaluating a new generation of LLM inference services, the most common debate is whether a tier that costs several times more per token than the previous flagship is actually expensive. Such comparisons often reach opposite conclusions because they treat “price per million tokens” as the only variable, while the bill is actually determined by multiple variables:
Bill ≈ (input tokens + output tokens) × unit price × number of calls× (1 - discount from cache hit rate)÷ effective task completion rate
In other words, unit price is only one term in the formula. If the new tier delivers higher output throughput, fewer failed retries, and meets the quality bar on the first attempt, the total spend for “completing the same batch of tasks” can actually go down. The more sound engineering metric is not unit price but cost per unit of effective output: how much it costs to complete one qualified task (a Q&A that passes acceptance on the first try, a code generation that passes tests).
2. The First Overlooked Variable: Output Throughput Determines Concurrency
LLM inference is divided into two phases: prefill (processing the input) and decode (generating output token by token). The output phase is token-by-token, and its speed directly determines how many concurrent requests a single card or instance can handle. In self-hosted or dedicated-instance deployments, the cost is approximately:
Hourly cost ≈ instance price ÷ (per-instance concurrency × 3600 / average response time)
If the average response time is cut in half, the same hardware can handle twice the concurrency, and the hardware amortization per request is halved. This explains a common phenomenon: a tier with a higher unit price but faster output can actually be cheaper in “dedicated resources, pay by time” scenarios. For token-billed managed services, this advantage translates into shorter queues and fewer timeout retries, indirectly reducing duplicate billing.
It is worth emphasizing that different vendors offer multiple rate versions such as “standard/accelerated” for the same tier, and their billing and throughput combinations vary widely. When comparing across versions, you must first put both under the same throughput basis; otherwise, the conclusion is meaningless.
3. Input/Output Ratio: Most Real Workloads Are Read-Heavy
The token structure of real business workloads is usually highly asymmetric: long-document summarization, code base Q&A, log and ticket analysis can have inputs of thousands to tens of thousands of tokens, while outputs are often only a few hundred tokens. In this case, if the input and output unit price multipliers of two tiers differ, the actual gap after weighting will deviate significantly from the ratio of the “headline unit price.” The correct approach is to weight by your own business’s average input/output length:
def blended_price(p_in, p_out, avg_in, avg_out):"""Blend unit price by real workload input/output ratio (per 1K tokens)"""return (p_in * avg_in + p_out * avg_out) / (avg_in + avg_out)# Example: long-input, short-output summarization scenarioold = blended_price(0.5, 1.5, 8000, 400)new = blended_price(1.2, 3.0, 8000, 400)print(old, new, new / old) # The multiplier is usually well below the headline output unit price multiplier
4. Engineering Cost-Reduction Levers: Caching, Batching, and Streaming
- Prefix caching: If fixed prefixes such as system prompts, tool definitions, and long documents can be reused, billing and computation for the repeated portion both decrease. Putting stable content first and variable content last is key to improving the hit rate.
- Batch asynchronous APIs: Offline batch processing is usually cheaper and higher-throughput than real-time APIs, suitable for data cleaning, batch labeling, and offline summarization.
- Streaming output and timeout governance: Streaming responses improve first-token latency and user perception. Combined with reasonable timeouts and retry limits, it avoids the waste of “failing halfway through generation and being billed for the whole segment again.”
- Output length constraints: Suppressing redundant generation through explicit format and length requirements is one of the most direct ways to save money.
SYSTEM = "You are a rigorous technical assistant. Output JSON only, no explanations." # Stable prefix, good for cache reusedef build_prompt(situation: str, question: str) -> str:# Stable content first, variable content lastreturn f"{SYSTEM}\nSituation:{situation}\nQuestion:{question}\nConstraint:Answer in no more than 200 words."
5. Quality Adjustment: First-Pass Rate Is the Denominator of Cost
If a cheaper tier requires two retries and more manual review, its “effective cost” is amplified. It is recommended to incorporate quality into a unified metric:
Cost per unit of effective output = blended unit price ÷ (first-pass rate × (1 - savings from reduced manual review))
For evaluation, sample 100–200 real business cases, define automatically verifiable acceptance rules (field completeness, format validity, whether unit tests pass, manual scoring thresholds), run both tiers separately, record the first-pass rate and average number of retries, and plug them into the formula above. This step is often more convincing than any official comparison material.
6. Latency, Stability, and Hidden Costs
- First-token latency and total duration: Affect user retention and timeout rates; timeout retries are a hidden item on the bill.
- Rate limits and quotas: Peak concurrency limits force you to add queuing and degradation logic, raising architectural complexity.
- Context length and truncation: Preprocessing overhead from extra-long contexts and rework caused by truncation must both be counted.
- Operations and migration costs: API differences, structured output capabilities, and tool-calling stability determine migration effort.
7. A Practical Selection Workflow
- Collect a real traffic profile: input/output length distribution, peak/off-peak concurrency, daily call volume.
- Calculate the blended unit price rather than comparing a single headline unit price.
- Run small-sample load tests on throughput and latency to determine per-instance concurrency capacity.
- Run quality evaluations to obtain the first-pass rate.
- Plug into the cost-per-unit-of-effective-output formula to reach a conclusion.
- Establish task tiering and routing: simple tasks go to the low-cost tier, complex tasks go to the high-performance tier, and set up a feedback loop to continuously calibrate routing thresholds.
Routing decision (pseudocode)if task complexity is low and input length < L1: route to economy tierelif strong reasoning or long context is needed: route to high-performance tierelse: route to mid tier with caching enabled
8. Conclusion
“Is it expensive” is a question missing a denominator. Once the basis is unified to cost per unit of effective output, a tier with a higher unit price but better throughput and a higher first-pass rate is not more expensive in most real businesses, and may even be cheaper. Developers are advised to run small-scale validation based on their own traffic profile and make decisions with data rather than multipliers. If you need elastic capacity for load testing and batch tasks, you can combine general cloud product capabilities such as container platforms, object storage, message queues, and monitoring/alerting to build evaluation and canary environments, turning cost evaluation into a sustainable engineering process rather than a one-time debate.
