Why Are Output Tokens More Expensive Than Input Tokens?
Output tokens typically cost three to five times more than input tokens in LLM pricing. This article explains the engineering reasons behind that gap: prefill is compute-intensive and parallel, while decoding is memory-bandwidth-bound and sequential, with a quadratic cost term that makes each additional output token more expensive. It also covers why cache hits can be orders of magnitude cheaper than misses, and offers practical advice on cost attribution, output reduction, batching, and capacity planning.
1. The Puzzle: Same Text, Two Different Prices
In LLM pricing tables, input and output are listed as separate columns, and the output rate is commonly three to five times the input rate. The first instinct is that vendors simply chose to price them differently. From an engineering perspective, however, this multiplier is not purely a commercial decision. It reflects two fundamentally different resource profiles that the two types of computation exhibit on hardware, ultimately reduced to a physical quantity: how many GPU-seconds each produced token consumes. Understanding this has direct value for teams doing capacity planning, cost attribution, and architecture selection.
2. Prefill: Compute-Intensive, with Costs Amortized
Processing the input side is called prefill. All N tokens of the prompt can be fed into the model at once, and the attention matrix is computed in parallel. The main costs come from two parts: the multiplication of weight matrices with activation matrices, on the order of O(N·d²); and the pairwise attention computation between tokens, on the order of O(N²·d), where d is the hidden dimension.
The key is amortization. Dividing total floating-point operations by N, the per-token cost approaches a constant (nearly independent of N when the d² term dominates). This workload is a standard matrix-matrix multiplication with high arithmetic intensity, which keeps the GPU’s compute units well fed. In practice, hardware utilization during prefill can typically exceed 80%. Put differently, what is sold on the input side is compute that is already running at full capacity, so the marginal cost is low.
3. Decode: Autoregressive and Serial, Bottlenecked by Memory Bandwidth
The output side is entirely different. The M output tokens must be generated one at a time: to compute token t, a full forward pass is required, reading the entire model’s weights from memory once and performing attention over the N+t−1 tokens accumulated so far; only after obtaining token t can token t+1 begin. This is a serial chain that cannot be parallelized.
The shape of this step is matrix-vector multiplication (GEMV). Compute consumption per step is small, yet all weights must be moved into on-chip storage, so the bottleneck is memory bandwidth rather than compute. An illustrative quantitative view conveys this imbalance:
# Illustrative order-of-magnitude relationships only, not specific product dataarithmetic_intensity_prefill = N # parallelism grows with sequence lengtharithmetic_intensity_decode = 1 # each step processes only one new token# Bytes read per decode step ≈ weight bytes + KV cache bytesbytes_per_decode_step = P_bytes + 2 * L * (N + t) * d * dtype_bytes
The weight bytes P_bytes are a fixed cost, while the KV cache term grows linearly with t. Hardware utilization stays low, so the same FLOPs require far more wall-clock time.
4. Where the Quadratic Term Comes From: Rising Marginal Cost per Token
Summing the work across M steps, the compute per token can be approximated as C + α(N+t): C is the fixed cost of one pass over the weights, and α is the marginal coefficient for attention. Summing over t from 0 to M−1:
Total ≈ C·M + α·(N·M + M(M−1)/2)
Here M(M−1)/2 is the quadratic term related to M². Its physical meaning is straightforward: each additional generated token makes the KV cache read in the next forward pass one notch larger, so marginal cost rises linearly with output length. The notion that “later tokens cost more than earlier ones” originates precisely here, rather than from linear accumulation.
Layering on the hardware utilization difference, once converted to GPU-seconds, the decode side is typically five to ten times more expensive than prefill. This is exactly the physical source of the three-to-five output/input ratio seen in the market. Deviations between models come mainly from pricing strategy and how much an architecture mitigates the decode bottleneck—for example, more aggressive attention compression, sparsification, and multi-token prediction all reduce that quadratic term and the fixed cost.
5. The Large Gap Between Cache Hits and Misses
For the same input, the price difference between a cache hit and a miss can reach two orders of magnitude. The token count is identical in both cases; the only difference is that on a hit, prefill does not need to be recomputed, and the already-computed KV cache is fetched and reused directly from memory or a higher tier of storage. This explains a counterintuitive phenomenon: in scenarios with long system prompts, long documents, and fixed few-shot prefixes, placing the stable prefix at the very front yields cost savings from improved hit rates that far exceed any prompt-level tuning.
In engineering terms, prefix stability matters: any single character change invalidates all subsequent cache, so timestamps, random IDs, and dynamic retrieval results should be placed as late as possible.
6. Practical Recommendations
- For cost attribution, track input, output, and cache hits as separate accounts; output is usually the main cost item in long-text generation scenarios.
- The benefit of shortening output is nonlinear; compressing redundant phrasing, structured output, and limiting maximum generation length are all effective.
- Batching and continuous batching can improve hardware occupancy during decode, but require balancing against time-to-first-token latency.
- Base capacity planning on GPU-seconds and memory bandwidth, not FLOPs alone.
- If using general-purpose cloud capabilities, combine container platforms for elastic scaling with logging services and monitoring alerts for usage observability, forming a reusable cost dashboard.
