Why Are Output Tokens More Expensive Than Input Tokens? A Deep Dive into Decoding Costs

    This article explains why most LLM API providers charge 3 to 5 times more for output tokens than for input tokens. By breaking down inference into the Prefill and Decode phases, it shows how prefilling is compute-bound while decoding is memory-bandwidth bound. It also covers how the linear growth of the KV cache introduces a quadratic cost term, how GPU-second costs compare across both phases, why cache hits create significant price gaps, and what practical steps teams can take to optimize token usage.

    1. An Often-Overlooked Pricing Detail

    When calling LLM APIs, the bill is typically split into two columns: input tokens and output tokens. For most providers, the output price per token is 3 to 5 times higher than the input price, and some models charge even more. The common first reaction is that “vendors are simply differentiating prices for marketing purposes.” From an engineering perspective, however, this ratio is not arbitrary. It directly reflects the real hardware cost difference between two distinct types of computation.

    To understand this, a single inference request needs to be broken down into two phases: Prefill and Decode. Prefill processes the entire input sequence of tokens at once, while Decode generates output tokens one by one. The two phases behave completely differently on a GPU.

    2. Prefill: A Compute-Bound Parallel Sprint

    The Prefill phase feeds a sequence of N input tokens into the model in a single pass. The representations for all tokens can be computed simultaneously. Matrix multiplication operands are large enough that every compute unit in the GPU can be fully utilized.

    At this stage, the performance bottleneck is compute capability (Compute Bound). The key metric is arithmetic intensity: how many floating-point operations can be completed per byte moved from VRAM. Prefill has high arithmetic intensity, allowing GPU compute utilization to reach very high levels. When translated into “GPU-seconds consumed per processed token,” the cost is quite low.

    3. Decode: A Memory-Bandwidth-Bound Serial Fetch

    The nature of the generation phase is completely reversed. Each step produces only one new token. The core operation at this step is a matrix-vector multiplication: the weight matrix is huge, but the vector being multiplied has only one row. The computational volume is very small, yet the weights must be read in full from VRAM.

    The bottleneck shifts from compute capability to memory bandwidth (Memory Bound). The GPU spends most of its time waiting for data to move from VRAM to registers and on-chip cache, leaving compute units idle. This is the fundamental reason why Decode utilization is significantly lower than Prefill, and it is the first source of “output being more expensive.”

    A schematic comparison of the loop structures for the two phases:

    1. # Prefill: process N positions in parallel at once, high arithmetic intensity
    2. hidden = embed(input_ids) # [N, d]
    3. for layer in layers:
    4. hidden = layer.forward_parallel(hidden) # Large matrix times large matrix
    5. # Decode: advance one position per step, weights must be fetched repeatedly
    6. past = prefill(input_ids)
    7. for step in range(M):
    8. logits = model.forward_single(past) # Large matrix times vector
    9. past = append_kv(past, sample(logits)) # KV cache keeps growing

    4. The Underestimated Quadratic Term: Linear Growth of the KV Cache

    The second source is more subtle. For every new token generated, its key and value vectors must be written to the KV cache. The next forward pass must then read the entire historical cache. This means the attention overhead at step t is proportional to N+t.

    Abstracting the per-token cost as C + α(N+t), where C is the fixed cost of one full pass through the weights, and α is the marginal coefficient for attention, and summing over t from 0 to M−1:

    1. Total cost ≈ C·M + α·(N·M + M(M−1)/2)

    The key is the M²/2 term. The cost on the output side does not grow linearly with length; it carries a quadratic component. The feeling that “each token is more expensive than the previous one” is precisely the practical manifestation of this quadratic term. The longer the context and the longer the output, the more significant this term becomes.

    5. Translated to GPU-Seconds: A 5 to 10x Physical Gap

    Combining the two factors above, when measured using a unified physical unit—GPU-seconds consumed to generate one token—decoding is 5 to 10 times more expensive than prefilling. The 3 to 5x output-to-input pricing ratio is the result of smoothing out this physical gap through commercial strategy. Different models have ratios fluctuating between 2.5 and 8 times, with differences arising mainly from two aspects: one is the pricing strategy orientation, and the other is the extent to which architectural designs mitigate the decoding bottleneck, such as more efficient attention structures, weight reuse, and parallel decoding schemes.

    6. The Massive Price Gap Between Cache Hits and Misses

    For the same input, the price difference between a cache hit and a cache miss can reach two orders of magnitude. The token count is identical in both cases; the only difference is that on a hit, there is no need to re-run Prefill, and the already-computed KV cache can be reused directly. This indirectly confirms the core conclusion of this article: Prefill itself accounts for a substantial portion of total cost, and the fact that vendors are willing to offer significant discounts for “skipping one Prefill run” shows that this computational overhead is real and expensive.

    7. Practical Implications

    • Place stable, large context blocks at the beginning to improve cache hit rates—the most direct cost-reduction measure.
    • Control output length, because the quadratic term is especially sensitive to long outputs. Structured and concise output formats yield clear benefits.
    • Pay attention to decoding efficiency when choosing an architecture, rather than looking only at parameter count and leaderboard scores.
    • Leverage monitoring alerts and logging services to separately track input and output token consumption and pinpoint the source of cost anomalies.

    Ultimately, output tokens being more expensive is not a pricing tactic. It is the projection onto the bill of two physical laws: “memory-bandwidth bound” and “quadratic growth of the KV cache.” Understanding this is essential for making correct trade-offs in application design and cost governance.