Why is the second call cheaper?
Prompt caching · Builder · 5 min · tokens, llm · after Tokens
Prompt caching reuses the work on a prompt’s opening when the next call starts with exactly the same text. Cached tokens are billed far below normal input, but only for long enough prefixes, sent again within minutes.
1 Guess first
2 Look
The same start, billed once
1 / 5call 1system prompt + 20-page doc · 10,000 tokensQ: summary? · 50call 2system prompt + 20-page doc · 10,000 tokensQ: risks? · 50Two calls about the same document. Only the question at the end differs.
token counts illustrative
Two calls about the same long document. Only the question at the end changes.
Only an identical opening is cached: written once at a small premium, then read at about a tenth of the price, if the next call comes soon and the prefix is long enough.
The prefix is the opening of your prompt: tools, system prompt, documents. Providers keep the work on a long prefix for a few minutes. If the next call starts with exactly the same text, those tokens are billed as cached input. So put what never changes first, and the question last.
4 You are the model
You are the cache. For each call, decide: hit or miss?
call 1 of 5 · Claude Sonnet 4.6, default cache
Same 10,000-token document, new question at the end, 2 minutes later
Anthropic prompt-caching docs (checked 2026-10-21)
You are the cache: hit or miss?5 Check
6 Say it back
7 Mission · 5 min
With a free Gemini API key, send Gemini 3.8 Flash the same long document (over 4,096 tokens) with two different questions at the end, a minute apart. Read usage.total_cached_tokens in both responses. Then move one sentence from the end to the very top and try again.
Three quick ones
Drawn at random from this lesson's pool; different next time.
Done?
Sources
- https://platform.claude.com/docs/en/build-with-claude/prompt-caching (checked 2026-10-21; no update date): 5-minute cache writes 1.25×, 1-hour 2×, reads 0.1× base input (0.05× on Opus/Sonnet 5.5, 0.025× on Fable/Mythos 5.1); default lifetime 5 minutes, refreshed on use; minimum 1,024 tokens on Claude Sonnet 4.6 (512–4,096 by model); “Cache hits require 100% identical prompt segments”; usage cache_read_input_tokens / cache_creation_input_tokens
- https://developers.openai.com/api/docs/guides/prompt-caching (checked 2026-10-21; no update date): on by default; minimum 1,024 tokens on GPT-5.6 and later; reads 0.1×, writes 1.25× (30-minute default); usage.input_tokens_details.cached_tokens
- https://ai.google.dev/gemini-api/docs/caching (updated 2026-10-13, checked 2026-10-21): implicit caching on by default for Gemini 2.5 and newer; minimum 4,096 tokens on Gemini 3.8 Flash; hits in usage.total_cached_tokens; the page does not say whether the free tier gets cache hits
- https://ai.google.dev/gemini-api/docs/pricing (updated 2026-10-19, checked 2026-10-21): Gemini 3.8 Flash input free of charge on the free tier
- Token counts (10,000 + 50) and the 1-unit base price in the picture are illustrative; the bills are arithmetic on Anthropic’s multipliers
Published Oct 21, 2026 · updated Oct 21, 2026