Long prompts look expensive per token and often are not. Cached input is billed at a small fraction of the normal input rate, so the same 200K-token context can cost twenty times less on the second call than on the first.
The provider keeps a prefix of your prompt in memory. On the next request, if the beginning of your prompt is byte-identical to a cached prefix, those tokens are billed as cache hits instead of normal input. The saving is large: cache-hit input is roughly 2% of the cache-miss rate.
Two properties follow, and both matter more than any tuning parameter:
Numbers from real traffic through this endpoint, not from a synthetic benchmark:
| Scenario | Cache hit rate |
|---|---|
| Single long prompt, sent twice back to back | 98.7% (18,688 of 18,937 tokens) |
| Agent / editor traffic over a day | 90.7% (390M of 430M tokens) |
The first row is the best case and shows the ceiling. The second is what a real mixed workload looks like. Design for the second number.
Because matching is prefix-based, order your prompt from most stable to least stable:
[ system instructions ] stable, identical every call [ tool / function specs ] stable [ retrieved documents ] stable within a session [ conversation history ] grows by appending only [ the new user message ] changes every call
Three habits follow directly:
Take a 100K-token context sent ten times in a session, with 200 output tokens per turn. On the official off-peak rate (input $0.15/M on a miss, $0.003/M on a hit):
| Case | Input cost for 10 calls |
|---|---|
| No caching — 10 misses × 0.1M × $0.15/M | $0.150 |
| Caching — 1 miss ($0.015) + 9 hits (9 × 0.1M × $0.003/M) | $0.0177 |
That is an 8.5× reduction on the input side, from the second call onward.
The rule of thumb: the saving is roughly 1 − (1 − h) × 0.02 of the
naive input bill, where h is your hit rate — but only on the calls
after the first. A single one-shot request never hits, so caching does
nothing for it. This is why agent and editor traffic (long stable prefix, many
turns) sees a far bigger saving than short chat traffic.
It also means a large prefix reused only twice is barely worth optimising for, while a modest prefix reused fifty times is worth a great deal. Optimise the reuse count, not the prefix size.
No. Caching is applied upstream automatically based on prefix matching. You cannot turn it on or off through the API, and there is no cache parameter to set.
It is managed by the upstream provider and is not guaranteed. Treat any hit as a bonus rather than something to depend on for cost planning.
Assume not. Keep a given workload on one key if you care about hit rate.
No. A cache hit returns the same computation, not a stored answer. The model still generates the response; only the input-side billing changes.