Reading the API Price Sheet
Part 3 of 4
Long-context surcharges, output tokens that cost more than input tokens, and cheap cache hits all fall out of the same cost model. Here is what each one tells us.
From Parts 1 and 2
A decode step takes at least \(\max(t_{\text{compute}}, t_{\text{memory}})\), with \(t_{\text{compute}} \approx 2BN_{\text{active}}/\text{FLOPS}\) and \(t_{\text{memory}} \approx (\beta N_{\text{total}} + B\,n_{\text{ctx}}\,s_{\text{kv}})/\text{BW}\). A GPU does about \(R \approx 300\) multiply-adds in the time it takes to read one weight. At scale, decode spends most of its time reading KV cache. A model is served from one scale-up domain, usually a rack.
AI labs don't publish their architectures, but they do publish prices. Prices can't stay far above cost for long, because a competitor would undercut them, and they can't stay below cost for long either. So the shape of a price sheet carries information about the hardware and the model behind it. This part reads the common features of LLM price sheets with the cost model from Parts 1 and 2.
- A long-context surcharge may mark the point where reading the KV cache starts to cost more than the compute. Treating one price step as that crossover suggests a KV cache of only a few kilobytes per token, which takes aggressive compression.
- Output tokens cost 4 to 8 times as much as input tokens because prefill shares its memory traffic across many tokens per pass, while decode reads everything for a single token per sequence. A 5x price ratio suggests decode spends about five times as long on memory as on compute.
- Cache hits cost a tenth of a normal input token or less because storing the KV cache and copying it back is much cheaper than recomputing it. The relative prices of short and long cache durations point at flash storage, not HBM.
- Very long contexts stay expensive because the memory traffic of decode grows linearly with context, and memory bandwidth improves only a little each hardware generation.
The cost of a longer context
Take one sequence in a big batch and ask what each new output token costs as its context grows. The compute per token barely changes: the model multiplies by the same active weights whether the context is short or long. The memory traffic per token grows, because each step reads the KV cache for every earlier token. With the batch large enough to amortize the weights, the memory time per token is about \(n_{\text{ctx}}\,s_{\text{kv}}/\text{BW}\), a straight line in the context length.
Below the crossover, a longer context is almost free, because the chip is waiting on compute anyway. Above it, every extra token of context adds cost. A provider that charges one flat rate either overcharges short prompts or loses money on long ones, so some use two tiers. When Google launched Gemini 3 Pro, it charged $2 per million input tokens and $12 per million output tokens for prompts up to 200K tokens, and $4 and $18 for longer prompts, with the whole request billed at the higher rate.
Not every provider does this. Anthropic prices the full million-token window of its recent large models at one flat rate, while its small Haiku 5.5 model charges five times as much once a prompt passes 100,000 tokens. Both fit the cost model. A small model does little compute per token, so KV reads overtake compute at a shorter context. A flat price on a large model suggests a very small KV cache per token, or long requests being averaged in with short ones.
Reading the KV cache size off a price step
Suppose the 200K-token step sits near the crossover. That's an assumption, but it's the natural place to put a price step. At the crossover, the KV read time per token equals the compute time per token:
\[ \frac{n_{\text{ctx}}\,s_{\text{kv}}}{\text{BW}} = \frac{2\,N_{\text{active}}}{\text{FLOPS}} \]Solve for the KV cache size per token, and use the hardware ratio \(R = (\text{FLOPS}/2)/(\text{BW}/\beta) \approx 300\) from Part 1:
\[ s_{\text{kv}} = \frac{\beta\,N_{\text{active}}}{R\;n_{\text{ctx}}} \]We don't know the active parameter count of a frontier model. A hundred billion is a reasonable guess. With 8-bit weights (\(\beta = 1\)) and \(n_{\text{ctx}} = 200{,}000\),
\[ s_{\text{kv}} \approx \frac{10^{11}}{300 \times 2 \times 10^{5}} \approx 1{,}700\ \text{bytes per token} \]If the model had 50 billion active parameters, it would be about 830 bytes. At 200 billion, about 3.3 KB. Either way it comes out at a few kilobytes at most. Is that plausible? The KV cache per token is
\[ s_{\text{kv}} = (\text{layers with their own KV}) \times 2 \times (\text{KV heads}) \times d_{\text{head}} \times (\text{bytes per value}) \]where the 2 counts keys and values. Plug in a few real and hypothetical designs:
A plain grouped-query attention model like Llama 3 70B stores about 328 KB per token. DeepSeek-V3 compresses keys and values into one small latent vector per layer and gets down to about 70 KB. Reaching a couple of kilobytes takes tricks that stack:
- Share one KV cache across many layers. Character.AI described sharing KV caches between neighboring layers, combined with a single KV head and mostly local attention, and reported that together these cut KV cache size by more than 20 times.
- Make most layers local. Gemma 3 uses five sliding-window layers, which only look back 1,024 tokens, for every global layer. Only the global layers' caches grow with context.
- Compress keys and values, as DeepSeek's latent attention does.
- Read only part of the cache. Sparse attention schemes such as DeepSeek's DSA pick a subset of past tokens for each new token. The full cache is still stored, but each step reads less of it, which lowers the bandwidth cost per token even though the capacity cost stays.
A combination of these can plausibly reach a few kilobytes per token of long-range context. The estimate has big error bars. The price step may not sit exactly at the crossover, prices include margins, and the active parameter count is a guess. But it points at kilobytes, not hundreds of kilobytes, and the gap matters. At 70 KB per token, a million-token context is 70 GB per sequence, more than a third of a GB200 GPU's HBM. At 2 KB it's 2 GB.
Why output tokens cost more than input tokens
Most price sheets charge 4 to 8 times as much for output tokens as for input tokens. Anthropic charges 5 times as much, Gemini 3 Pro 6 times, and GPT-5 8 times. The reason is the difference between prefill and decode.
Text the model didn't write, such as the system prompt, the user's message, a file, or a tool result, is known all at once. So the model can push all of those tokens through in a single pass. That's prefill. Text the model writes has to come out one token per pass. That's decode.
Now look at the cost of one pass that handles \(n\) new tokens per sequence. The memory traffic is the same as for a decode step: read the weights once, and read each sequence's existing KV cache once. The new tokens' keys and values are computed on the chip as part of the pass. The compute is \(n\) times larger, so the cost per token is
\[ \frac{t}{n} \approx \max\!\left(\frac{2\,N_{\text{active}}}{\text{FLOPS}},\ \ \frac{\beta N_{\text{total}}/B + n_{\text{ctx}}\,s_{\text{kv}}}{n \cdot \text{BW}}\right) \]per sequence in the batch. The memory term is divided by \(n\).
Prefill passes cover hundreds or thousands of tokens, so the memory term disappears and prefill runs at the compute floor. Decode is the \(n = 1\) case, where the memory term is as large as it gets. If prices track costs, an output price five times the input price says that in decode, the memory time per token is roughly five times the compute time. Part 1's DeepSeek-V3 example, with HBM full of 30,000-token contexts at 70 KB per token, had KV reads at about 17 times compute. The gap means that either typical serving is less KV-heavy than that example, through shorter contexts or smaller KV caches per token, or output prices don't track decode cost closely. A KV cache of a few kilobytes per token, as the previous section suggested, would close most of it, because many more sequences would fit in HBM and the compute per step would rise to match.
Prefill isn't free of its own long-context cost, though. Each prompt token attends to every token before it, and in prefill that attention costs real compute as well as memory traffic. In Llama 3 70B, attention's multiply-adds per token equal the weight multiply-adds at about 53,000 tokens of context (80 layers times 64 query heads of width 128, for both the key and value products, against 70 billion weights). Long prompts get expensive to prefill too, which is another reason input prices step up for very long prompts.
Why cache hits are cheap
Prompt caching lets you reuse the KV cache for a prefix you've sent before, such as a long system prompt or a codebase. Anthropic's prices for its Claude 4.x models, as multiples of the normal input price, are:
| Operation | Price vs. normal input |
|---|---|
| Normal input (no caching) | 1× |
| Write to cache, kept 5 minutes | 1.25× |
| Write to cache, kept 1 hour | 2× |
| Read from cache (a hit) | 0.1× |
Its newest models charge even less for a hit: 0.05× for Opus 5.5 and Sonnet 5.5, and 0.025× for the Fable models. The write prices are the same.
There are two ways to get a prefix's KV cache onto the GPUs. You can compute it from the token IDs, which means running prefill again. Or you can have kept it somewhere and copy it back. A cache miss means you threw it away and have to recompute it. The gap of 10 times or more between a normal input token and a cache hit is the gap between those two options.
Where do you keep it? Each storage tier has two costs for holding data. Holding it takes capacity, for as long as you hold it. Getting it back takes bandwidth, once. Recomputing has no holding cost but a large retrieval cost. HBM has a large holding cost, since HBM is the most expensive memory in the system, but costs nothing to retrieve from, because the data is already where it's needed. Host DRAM and flash are much cheaper to hold data in, but the data has to be copied back into HBM before use.
A storage device is used efficiently when its capacity and its bandwidth run out at about the same time. If you're holding data for time \(T\) and then reading it once, that happens when
\[ T \approx \frac{\text{capacity}}{\text{bandwidth}} \]which is the device's drain time, the time to read the whole thing once. It's the same balance argument as compute against memory in Part 1, applied to capacity against bandwidth. Database designers know a version of it as the five-minute rule, from Jim Gray and Franco Putzolu's 1987 paper on when to keep data in memory versus on disk.
Both cache durations land in flash territory. HBM is far too expensive for this. Its drain time is about 25 ms, so holding a prompt there for five minutes costs about 12,000 times as much as reading it once. Host DRAM fits hold times of seconds. Flash fits minutes to a couple of hours, which covers both. Hard disks would suit data held for a day.
The prices fit this picture in one more way. A cache write has to run prefill anyway, which costs the normal 1×. So the extra 0.25× for a five-minute write is the price of holding the data for five minutes, and the extra 1× for a one-hour write is the price of holding it for an hour.
Holding for 12 times as long costs only 4 times as much. If both durations used the same storage at the same rate, the hour would cost 3× extra, not 1×. That's consistent with the hour living on cheaper storage, such as larger, slower flash drives, whose drain times run to hours. Prices aren't costs, and a provider may simply round to friendly numbers, so treat this as a hint.
Why long contexts stay expensive
Context windows went from 2,048 tokens in GPT-3 (2020) to 8K and 32K in GPT-4 (early 2023), then to 128K and 200K by the end of 2023, and to a million with Gemini 1.5 in early 2024, later two million. Llama 4 Scout claims ten million. Several flagship models offer a million tokens today. Advertised windows keep growing, but serving very long contexts at scale stays expensive, and the cost model says why.
The compute per token barely depends on context length. The memory traffic per decoded token grows in proportion to it, and so does the memory each sequence occupies. Fewer long sequences fit in HBM at once, so batches shrink and the weights are amortized over fewer tokens. HBM bandwidth improves by a factor of two or so per hardware generation, which doesn't come close to keeping up with 10x or 100x jumps in context.
One argument against needing continual learning is that a model could learn on the job in context, if it could hold, say, a month of work. That might be a hundred million tokens. At 70 KB per token that's 7 TB per sequence, more than half of an NVL72's entire HBM. Even at 2 KB per token, it's 200 GB per sequence. Sparse attention reduces how much each step reads, but it still has to store everything, and attending to too few past tokens hurts quality. Contexts that long will need architectural changes as well as faster memory.
In Part 4, the last part, we turn from serving to training and ask how much data a model should be trained on, given how many tokens it will serve.
Diagrams are drawn in TikZ.