# Why tokens cost differently

Output, cache writes, fresh input and cache reads are priced in a fixed order, so how your tokens arrive matters as much as how many there are.

> Tokens come in four kinds, priced in a stable order from cheapest to priciest: cache read, fresh input, cache write, output. The ordering holds across providers; the exact multiples do not.

Source: https://ai-sw-factory.mellicci.dev/cost/why-tokens-cost-differently

**Diagram:** Four kinds of token, ordered from cheapest to priciest; the order holds across providers, the multiples do not.

- Cache read — replay of held text
- → dearer
- Fresh input — read in parallel
- → dearer
- Cache write — pays to hold a prefix
- → dearer
- Output — generated one by one

A bill counts tokens, but it does not price them equally. A token the model writes costs several times more than a token it reads, and a token it replays from storage costs a fraction of one it reads for the first time.

Two numbers describe a session: how many tokens it used, and what kind they were. The second matters as much as the first. [Tokens, turns and context](https://ai-sw-factory.mellicci.dev/cost/tokens-turns-and-context) covers the count; this page covers the kinds.

## Why it matters

Two sessions can use the same 200,000 tokens and cost very different amounts. If you only watch the total, you cannot tell which one you are running.

It also explains advice that otherwise looks arbitrary: why a long, stable prefix is worth protecting, why a chatty model is dearer than a quiet one, and why a cache that expires unused can cost more than having no cache at all.

## How it works

The order follows how much work the provider does for each kind of token.

| Kind | What happens | Price position |
|---|---|---|
| Output | The model generates one token, then the next conditioned on it. This cannot run in parallel. | Priciest, usually by several times fresh input |
| Cache write | You ask the provider to hold a prefix in fast storage. The storage is charged up front. | More than fresh input |
| Fresh input | The model reads text it has no stored copy of. Reading runs in parallel. | The middle |
| Cache read | The provider already holds this exact prefix and replays it. | Cheapest, commonly around a tenth of fresh input |

A cache write is a bet. You pay extra now so that later calls pay the cheap read price, and you win only if the same prefix is reused before it expires. [Prompt caching](https://ai-sw-factory.mellicci.dev/cost/prompt-caching) explains what makes a prefix match, and [Cache lifetime](https://ai-sw-factory.mellicci.dev/cost/cache-lifetime) explains how long it is held.

The exact multiples come from the provider, differ by model and change over time. Treat every figure on this page as a rule of thumb, not a quote.

## Example

The `ticket-service` team has four developers, each with a coding agent, and their agent spend doubled last month. Take one long session of 200,000 tokens. In both runs the token count is the same, and so is the model's output: 4,000 tokens.

The table prices the two runs in relative units. Fresh input is 1 unit per token, a cache read 0.1, a cache write 1.25 and output 5. These multiples are illustrative, not any provider's rates.

| Token kind | Mostly cache reads | Mostly fresh input |
|---|---|---|
| Cache read (0.1) | 180,000 tokens = 18,000 | 0 |
| Cache write (1.25) | 10,000 tokens = 12,500 | 0 |
| Fresh input (1) | 6,000 tokens = 6,000 | 196,000 tokens = 196,000 |
| Output (5) | 4,000 tokens = 20,000 | 4,000 tokens = 20,000 |
| **Total** | **200,000 tokens = 56,500 units** | **200,000 tokens = 216,000 units** |

The second run costs nearly four times as much for the same token count. Nothing about the work changed; the context was simply not served from the cache, so every call paid the fresh-input price for it. The input side alone differs by about five times.

## What helps, what hurts

Helps:

- Keep the start of the conversation stable, so later calls match the held prefix and are billed as cache reads. See [Prompt caching](https://ai-sw-factory.mellicci.dev/cost/prompt-caching).
- Return before the cache expires, so the write you paid for is read again. See [Cache lifetime](https://ai-sw-factory.mellicci.dev/cost/cache-lifetime).
- Ask for what you need and no more, because every generated token is the priciest kind. See [Model and reasoning choice](https://ai-sw-factory.mellicci.dev/cost/model-and-reasoning-choice).

Hurts:

- Changing something early in the context, such as an instruction or a tool, so the whole remainder is billed as fresh input again.
- Paying for cache writes that nobody reads, because the session ended or the entry expired first.
- Judging a session by its total token count alone.

## Trade-offs

- **A cache write costs more than fresh input.** For a one-off call that is never repeated, caching loses money.
- **Shorter output is not always better.** Terse answers can drop the reasoning or detail you needed, and a second request costs more than a longer first reply.
- **Rules of thumb age.** The order is stable; any multiple you memorize will drift as providers change.

## Related

- [Tokens, turns and context](https://ai-sw-factory.mellicci.dev/cost/tokens-turns-and-context) - what a token is and what each call re-reads.
- [Prompt caching](https://ai-sw-factory.mellicci.dev/cost/prompt-caching) - what makes re-reading cheap.
- [Cache lifetime](https://ai-sw-factory.mellicci.dev/cost/cache-lifetime) - when the cheap read stops.
- [How coding agents work](https://ai-sw-factory.mellicci.dev/fundamentals/how-coding-agents-work) - the loop that sends each call.

## Key terms

- **Output token** - a token the model generates; the priciest kind.
- **Fresh input** - context read without a cache; the middle.
- **Cache write** - paying to hold a prefix; dearer than fresh input.
- **Cache read** - replaying a held prefix; the cheapest kind.
