Token Engineering · ~7 min
A prompt cache is the cheapest token there is — but it only pays out if your prefix is stable and your tokenizer never moves underneath it.
The first two Rights cut tokens you send. This one makes the tokens you re-send nearly free. A prompt cache discounts any leading run of tokens identical to a previous call — so the discount is a property of ordering, and it is silently fragile to anything that changes how text becomes tokens.
Caching matches on a prefix. The model can reuse compute only up to the first token that differs from the previous request. One byte of drift near the front voids everything after it. So the discipline is brutally simple: put what never changes first, what changes every call last.
| Position | Put here | Why |
|---|---|---|
| Front (cached) | System prompt, tool schemas, fixed instructions | Identical across calls → long shared prefix |
| Middle | Stable reference docs, retrieved corpus that rarely changes | Still in the shared run if ordered consistently |
| Tail (uncached) | The user turn, timestamps, per-call IDs | Changes every call — keep it out of the prefix |
Caching matches on tokens, not characters. So the matching prefix only survives while the same text maps to the same token sequence. A model upgrade that ships a new tokenizer remaps that text — the cached prefix no longer exists in the new vocabulary, and every previously cached token is gone. The pricing page shows no change, which is exactly why this bites.
Anthropic documents the Claude Opus 4.7 tokenizer as producing roughly 1.0–1.35x as many tokens
(up to ~35% more, varying by content) for the same text versus prior models — at unchanged $5 / $25 per MTok pricing
and an unchanged 1M-token window. Simon Willison measured the real spread against the count_tokens
endpoint, and it is workload-shaped:
| Input | 4.6 → 4.7 tokens | Multiplier |
|---|---|---|
| System prompt (raw text) | 5,039 → 7,335 | 1.46x |
| 30-page text-heavy PDF | 56,482 → 60,934 | 1.08x |
| 682×318 image | 310 → 314 | ~1.00x |
| 3456×2234 high-res PNG | 1,578 → 4,744 | 3.01x |
Flat per-token price × a higher token count is a price increase the pricing page does not show. A migration that re-tokenizes your stable system prefix at 1.46x both inflates spend and invalidates the cache that was hiding that prefix's cost — two hits from one swap.
The headline multiplier is a spread, not your number. Anthropic's migration guide names concrete pre-cutover work — and the cache-fit check is part of it. Re-run representative prompts through both tokenizers, then update the envelopes the new count shifts:
max_tokens, compaction triggers, and prompt-cache fit checks — the same source now fills more of the window, so caches and compaction thresholds drift.And remember the multiplier overcounts: a more capable model can finish tasks in fewer retries, and effort / task-budget controls can absorb part of the lift. Tokenizer arithmetic alone overestimates the migration cost — so forecast from your workload, then check the cache actually still hits after cutover.
max_tokens, compaction triggers, and cache-fit all shift with the new count.Retrieval practice — recall, don't peek
Question 1A prompt cache discounts a call based on…
Question 2Putting a per-call timestamp before your stable system prompt…
Question 3A model upgrade that ships a new tokenizer does what to a cached prefix?
Question 4Opus 4.7 tokenizes the same text at roughly… (pricing and window unchanged)
Question 5 · spaced recall from an earlier lessonTo cut output tokens on a code edit, you have the model return…