Claude prompt caching: cache_control, TTL and pricing
Prompt caching lets Claude reuse the processed prefix of a request instead of reading it again. Mark the end of the stable part with cache_control: {"type": "ephemeral"}, and later requests that start with exactly the same content read it from the cache at a fraction of the input price.
How it works
The cached prefix is built from tools, then system, then messages, up to and including the block that carries cache_control. Put stable content first and anything that changes per request after the breakpoint. Matching is exact, so one changed byte before the breakpoint means a miss.
You can use automatic caching, a single top-level cache_control field that moves the breakpoint forward as a conversation grows, or explicit breakpoints on individual blocks. A request can have up to 4 breakpoints. For each one, the API looks back at most 20 positions for an entry an earlier request wrote.
Prompts shorter than the model minimum are processed without caching and with no error. The minimum is 512 tokens on Claude Opus 5 and Opus 5.5, 1,024 on Sonnet 5 and Sonnet 4.6, and 4,096 on Haiku 4.5.
Lifetime and price
The default lifetime is 5 minutes. Add "ttl": "1h" for one hour. Each hit resets the timer at no extra cost. A 5-minute write costs 1.25x the base input price, a 1-hour write costs 2x, and a read costs 0.1x on most models. On Opus 5.5 and Sonnet 5.5 a read costs 0.05x.
A cache entry becomes readable only after the first response starts. If you send 20 requests with the same prefix at the same moment, all 20 write and none read. Send one first, wait for it to start responding, then send the rest.
Reading the usage fields
cache_read_input_tokens is what came from the cache, cache_creation_input_tokens is what was written, and input_tokens is only the tokens after the last breakpoint. Total input is the sum of all three. A request with 18,000 read, 2,000 written and 350 uncached consumed 20,350 input tokens.
Where the exam catches people
Believing input_tokens is the whole prompt: with caching it counts only the tokens after the last breakpoint.
Believing parallel requests share a fresh entry: the entry is readable only once the first response has started.
Believing a short prompt that never caches is an error: below the model minimum the request simply runs uncached.
Believing the order is system, tools, messages: the prefix is tools, then system, then messages.