Why Output Tokens Cost More: Compute Bottlenecks and LLM API Pricing
Output tokens often cost more than input tokens because autoregressive generation uses hardware differently from prompt processing. This article explains how prefill, memory bandwidth, KV cache growth, and serving constraints influence inference costs—and why those costs do not imply a fixed pricing ratio. It also outlines practical ways to reduce spending while preserving task quality and latency.
1. Equal Token Counts Do Not Mean Equal Execution Costs
LLM APIs typically count input and output tokens separately, then charge each at its respective rate. Both are units of tokenized text, so why are output tokens often more expensive?
The key distinction is that a token is a billing unit, not a standardized unit of computational work. Processing known text and generating unknown text step by step differ substantially in execution, hardware utilization, cache usage, and service latency.
For a typical autoregressive language model, a request has two main phases:
- Prefill: Process the existing input, compute intermediate results across model layers, and build the cache needed for generation.
- Decode: Predict the next token from the current context, append it to that context, and repeat.
Higher output prices largely reflect the resource efficiency and sustained resource usage of decoding. However, prices are not a direct translation of hardware costs. No particular input-to-output price ratio should be treated as a universal technical rule.
2. Why Input Processing Can Achieve Higher Hardware Throughput
Suppose a prompt contains N tokens. Because all of those tokens are known when the request arrives, the model can process multiple positions in parallel during prefill.
This does not remove causal constraints. With causal attention, each position can still attend only to permitted earlier positions. However, computations across these positions can be organized into batched matrix operations, without waiting for a preceding token to be selected as they must during generation.
Larger Matrix Operations Amortize Weight Reads
A model’s linear transformations can be represented as multiplication between an input matrix and a weight matrix. When multiple tokens are processed together, the same weights participate in calculations for multiple positions, increasing reuse of the weight data after it is read.
This generally improves arithmetic intensity: more computation can be performed for a given amount of data movement. With suitable input lengths, batch sizes, and operator implementations, accelerators can achieve higher compute utilization.
By contrast, generating one token at a time for a single request makes linear-layer operations more like matrix-vector multiplication, with fewer opportunities to reuse weights.
Input Computation Is Not Always Linear
A lower input-token price does not mean prefill contains no expensive operations.
With standard global attention, part of the prefill computation scales quadratically with input length. Efficient implementations can reduce intermediate storage and data movement, but they do not make global attention linear in compute cost for arbitrary context lengths.
Input-processing costs therefore depend on model architecture, context length, batch size, and implementation. A lower unit price often reflects more efficient batched execution—not negligible computation.
3. Why Decoding Can Be Limited by GPU Memory Bandwidth
The defining feature of decoding is the dependency between generation steps.
In conventional autoregressive generation, the model must obtain the current token before it can construct the input for the next step. Producing M tokens for one request therefore typically requires M decoding steps. Each step is relatively small, but it still accesses model weights and the historical cache.
Less Computation Does Not Necessarily Mean Less Execution Time
For single-request or low-batch decoding, many linear layers resemble matrix-vector operations. In this setting:
- The accelerator may have high theoretical compute capacity.
- Each step performs relatively little arithmetic.
- Much of the execution time is spent reading weights and cache data from device memory.
- Performance is limited by data movement rather than compute capacity.
This is the memory-bandwidth bottleneck commonly associated with decoding.
Floating-point operation counts alone are therefore insufficient for estimating inference cost. Other important measures include accelerator time per request, actual memory requirements, data-transfer volume, and the number of concurrent requests a service can reliably support.
Batched Decoding Helps, but Serving Constraints Remain
Combining the next-token computations of multiple requests into a batch improves weight reuse and turns small operations into larger matrix computations.
Online requests, however, have different input lengths, output lengths, and completion times. The serving system must continuously adjust batches as requests arrive and finish, while reclaiming cache memory.
Larger batches generally improve throughput but can increase waiting time. A service with strict time-to-first-token or inter-token latency targets cannot wait indefinitely for enough requests to form a large batch.
Peak throughput in an offline benchmark therefore does not directly represent the per-request cost of a real-time API.
4. How Cache Growth Creates a Quadratic Output Term
To avoid recomputing all previous tokens at every generation step, models typically store the keys and values needed by attention layers. These stored tensors are known as the KV cache.
The cache reduces repeated computation, but it does not eliminate access to historical context.
Let the input length be N and the number of tokens already generated be t. Under standard global attention, with the complete cache retained, the next step attends to a history of approximately N + t tokens.
A simplified model of per-step work is:
W(t) ≈ C + α(N + t)
Here:
- C represents relatively fixed per-step work, including model computation and weight access.
- α represents the incremental attention computation and cache-access work associated with each additional context token.
- N + t is the accessible context length.
Summing from t = 0 to M − 1 for an output of M tokens gives:
W_total ≈ CM + α[MN + M(M − 1)/2]
This expression separates the work into three components:
- CM: The baseline work repeated at every decoding step, growing linearly with output length.
- αMN: Each output token accesses the original input context, so longer inputs increase cumulative generation work.
- αM(M − 1)/2: Later tokens access an increasingly long generated history, creating a cumulative term that grows quadratically with output length.
Under these assumptions, the marginal work required to generate one more token increases as generation progresses.
However, this is an approximation of work, not an exact billing formula. Computation and data access cannot simply be added together and converted directly into execution time. Actual performance also depends on batch size, cache layout, operator efficiency, and overlap between computation and data movement.
Local attention, bounded attention windows, or other architectures can also change how historical access grows.
It is therefore too strong to say that every later token must be noticeably slower or more expensive. The more precise conclusion is that attention over the full history creates a gradually increasing context-access burden.
5. Output Generation Also Occupies Serving Capacity
Output costs arise not only from computation but also from how long a request remains active.
KV Cache Memory Grows with Context Length
For common attention architectures, the KV cache size of a single request can be approximated as:
KV cache size ≈2 × number of layers× context length× number of KV heads× head dimension× bytes per element
The factor of 2 accounts for keys and values.
This formula captures the main scaling relationships. Actual memory usage may also include alignment, block management, and other runtime overhead. In general, a growing context requires a larger cache.
A request that generates for a long time consumes compute and continues to occupy device memory that could serve other requests. Because memory capacity often limits concurrency, this occupancy creates an opportunity cost.
Long Outputs Increase Scheduling and Tail-Latency Pressure
When a short request finishes, the system can quickly reclaim its cache and admit new work. A long-running generation request remains active across many scheduling cycles.
If many long requests run concurrently, the service must balance throughput, fairness, and responsiveness. To maintain stable latency targets, operators may also need spare capacity rather than keeping devices at their theoretical maximum load.
This is another reason output pricing cannot be explained solely by the operation count of a single forward pass.
6. Why Cache Hits Can Make Input Tokens Cheaper
When multiple requests share the same prefix, a system that supports prefix KV cache reuse can avoid repeating some prefill work.
For example, requests may use identical system instructions or fixed reference material. After the first computation, subsequent requests that meet the cache-matching requirements can reuse those results and process only the additional content.
A cache hit is not free, however:
- Cached data occupies storage.
- Matching, indexing, and cache lifecycle management require resources.
- Cached data may need to move from another storage tier to the execution device.
- Differences in model versions, input content, or relevant computation settings may prevent reuse.
- The cached prefix may still be accessed by attention during subsequent decoding.
Caching primarily avoids repeated prefill; it does not eliminate computation for the entire request.
Some services may offer substantial cached-input discounts. Their size also depends on billing policy, cache location, reuse probability, and transfer costs. A specific discount should not be treated as an industry-wide rule.
7. Why Technical Bottlenecks Do Not Imply a Fixed Price Ratio
Decoding is typically less efficient than prefill, which provides an important technical basis for higher output prices. Final prices also reflect factors such as:
- Model size and architecture
- Weight and cache storage precision
- Inference engine efficiency
- Average batch size and traffic variability
- Latency and availability targets
- Resource requirements of long-context requests
- Hardware, storage, networking, and operational costs
- Market competition and commercial pricing strategy
In particular, a claim that decoding uses several times more accelerator time should not be interpreted as a requirement for output tokens to cost the same multiple of input tokens.
The accelerator-time comparison requires clearly defined benchmark conditions. The price ratio is a commercial decision. The two are related, but they do not map one-to-one.
A meaningful comparison should at least control for the model, hardware, input and output lengths, concurrency, and latency targets. Without those conditions, ratio-based claims can have little explanatory value.
8. How Developers Can Optimize API Costs
Reduce Output That Adds No Value
Because output tokens often have a higher unit price, start by eliminating generation that does not contribute to the task.
Specify the response structure, retain necessary fields, avoid repeated explanations, and set an appropriate output limit. The goal is not to make every answer as short as possible, but to balance completeness against generation cost.
Manage Both Input and Output Length
Long inputs increase input charges and may also increase historical-context access at every decoding step.
For retrieval tasks, select genuinely relevant material rather than placing every available document into the context. In multi-turn conversations, periodically consolidate useful history so that irrelevant content does not accumulate indefinitely.
Context compression can omit important information, however. Validate task quality rather than judging an optimization solely by the number of tokens saved.
Keep Reusable Prefixes Stable
If the service supports prefix caching, place stable instructions and shared background before frequently changing user content. Avoid unnecessary changes to the reusable prefix.
Cache eligibility and billing depend on the service’s actual rules. Text that looks similar does not necessarily qualify for cache reuse.
Measure Cost per Successful Task
For simple input-and-output pricing, request cost is:
Request cost =input token count × input unit price+ output token count × output unit price
If cached input or other billable items are involved, account for them separately. Units must also be consistent: rates quoted per million tokens must be converted accordingly.
A more useful business metric is:
Cost per successful task =total API spending ÷ number of successfully completed tasks
Overly compressed output may be incomplete, leading to retries or manual corrections. Splitting one request into several to reduce its token count may repeatedly send the same background context.
Effective optimization reduces spending while preserving quality and meeting latency requirements.
9. Conclusion
Output tokens usually cost more not because they are inherently more complex as text, but because conventional autoregressive generation advances sequentially. Low-batch decoding is more likely to be constrained by memory bandwidth, historical caches grow over time, and active requests continue to occupy memory and scheduling capacity.
Input prefill is better suited to high-throughput matrix operations and can reuse cached results when the relevant conditions are met. These different execution paths provide a technical basis for separate input and output prices.
The price ratio, however, is not a fixed physical constant. Understanding that distinction helps developers move beyond comparing token rates alone and make better cost decisions based on context size, output value, cache reuse, task success, and latency targets.
