Whether a request is served from a prompt cache depends on the model family. You do not switch it on.
| Family | Caching through this API |
|---|---|
| GPT | Automatic. A request that begins with the same text as an earlier one reads that part from the cache. |
| Gemini | Automatic, on the same basis. |
| Claude | None. Claude caches only where a request marks a cache breakpoint, and this API sets none, so a Claude model reads nothing from a cache here. |
The models that have a prompt cache, and their cache read and write prices, are in the Models table. For the other families this page makes no claim.
- Keep the start of the request the same: the system prompt, the tool definitions and the earlier messages, in the same order.
- Put what changes, such as the latest question, at the end.
Neither endpoint reads cache_control. A request that sends it runs normally, and does not make a Claude model cache.
{
"usage": {
"prompt_tokens": 2000,
"completion_tokens": 8,
"total_tokens": 2008,
"prompt_tokens_details": {
"cached_tokens": 1900
}
}
}- OpenAI-compatible:
usage.prompt_tokens_details.cached_tokensis the part ofprompt_tokensread from the cache. When tokens were written to the cache,cache_creation_tokenssits beside it. The block is left out when there was neither. - Anthropic-compatible:
usage.cache_read_input_tokensandusage.cache_creation_input_tokensare always present.input_tokenscounts only the tokens that were not cached. - Streaming: the OpenAI-compatible stream ends with a chunk that carries
usage, and the Anthropic-compatiblemessage_deltaevent carries it.
Usage shows the share of input served from the cache as Cache hits, for the whole account or for one project or key. The request log lists input, cached, cache write and output tokens for each request.