Why Inference Costs Drop the More You Use It
This article explains why heavy token consumption does not translate into proportional inference costs. It breaks down the real cost structure of prefill, decode, and KV cache overhead, then shows how prefix cache reuse, speculative decoding, and the nature of coding workloads combine to make repeated input nearly free. It closes with practical engineering steps for controlling inference costs through stable prefixes, context management, batching, observability, and elastic capacity planning.
1. The Misread “Million-Dollar Token Bill”
A developer shared an annual subscription bill: roughly $200 for the year, yet consuming about 16 billion tokens. Converted at public pay-as-you-go API prices, the equivalent value could reach the six-figure range. Independent measurements added more context: mid- and low-tier subscriptions can burn through hundreds of millions of tokens per week, while higher tiers can consume billions per week, and third-party analysts put the effective usage multiple at 40x to 70x.
The first reaction to numbers like these is usually “the vendor is subsidizing users.” But that intuition misses a key premise: a token is a unit of measurement, not a unit of equivalent work. The same token might be newly generated content after a full forward pass, a historical context segment served directly from cache, or one of several positions verified in a single speculative decoding step. Cost is not linearly related to token count; it is modulated by cache hit rate, context reuse rate, and decoding strategy.
2. Breaking Down the Real Cost Structure
The cost of a single inference request can be roughly split into three parts:
Total cost ≈ Prefill cost + Decode cost + VRAM and scheduling overhead= Input context processing + Token-by-token autoregressive generation + KV Cache storage/swap in and out
The key point is that the prefill stage must compute and write the KV cache for the entire input context, which is compute-intensive. The decode stage, on the other hand, reads the full historical KV for every token generated, which is memory-access-intensive. As a multi-turn conversation keeps appending history, re-prefilling every time makes cost degrade quadratically with context length. Once the prefix KV is reused, however, the repeated input portion costs almost nothing beyond a cache read.
This is where “cache reads are nearly free and long sessions become far more efficient” comes from: what the vendor actually pays for is the first write into the cache and the compute for the new suffix, not the historical prefix that gets read repeatedly.
3. Speculative Decoding: Verifying Multiple Positions in One Forward Pass
The bottleneck of autoregressive decoding is memory access rather than compute, and the GPU sits largely idle when generating short tokens. Speculative decoding has a small, fast draft model guess several tokens in a row, then the main model verifies them in parallel with a single forward pass. Accepted tokens are committed directly; rejected positions are rolled back and re-guessed.
The benefit depends entirely on the acceptance rate:
Speedup ≈ Average accepted length / (1 + draft overhead ratio)
In highly predictable scenarios such as code completion, formatted rewriting, and repetitive template generation, the acceptance rate is naturally high, so the effective unit cost is significantly diluted. This also explains why “coding scenarios” are the most profitable workload type in inference economics.
4. Why Coding Workloads Are the Optimal Cost Profile
Coding-oriented AI tools have workloads with three characteristics:
- Highly stable prefix: system prompts, repository rules, code conventions, and already-read files barely change throughout a session, yielding a very high cache hit rate;
- Highly predictable output: completion and refactoring are strongly constrained by syntax, so speculative decoding acceptance rates are high;
- Trimmable context: retrieval loads relevant snippets on demand, avoiding meaningless full concatenation.
Combined, these make nominal token consumption huge while the proportion of “new tokens” that actually trigger full computation stays low. Users perceive that “the quota is almost impossible to exhaust,” while on the vendor side there are high margins driven by cache and decoding optimizations.
5. Engineering Practices for Consumers
To genuinely drive inference costs down, consider the following directions:
- Stable prefix: place unchanging instructions, conventions, and dependency notes at the front in a fixed order, and avoid inserting dynamic content ahead of them, which would invalidate the cache entirely;
- Control context growth: use retrieval-based on-demand injection plus historical summary compression instead of endlessly appending raw conversation;
- Batching and concurrency control: merge small requests to reduce scheduling and cold-start overhead;
- Build observability: use logging services and monitoring alerts to track cache hit rate, average accepted length, and context length distribution, letting data drive optimization;
- Elastic capacity planning: use container platforms’ elastic scaling and message queues to smooth out spikes and handle burst traffic.
In related practice at Baidu AI Cloud, these ideas are typically combined into a three-part set of “cache-friendly request construction + full-chain observability + elastic resource scheduling,” rather than simply relying on scaling compute.
6. Conclusion
Both “the subscription model is a goldmine” and “the vendor is throwing money around” are misjudgments that come from treating tokens as work. The real picture is that cache reuse pushes the cost of repeated input close to zero, speculative decoding turns the memory-access bottleneck into parallel verification, and coding workloads happen to max out both optimizations. Understanding this inference economics is what lets you make the right trade-offs in architecture design, cost budgeting, and capacity planning — optimizing hit rate is more effective than piling on compute.
