Prompt caching
Repeated and continued prompts are served from a cache, so they start sooner and their cached input is billed at the cached rate shown on the Models page. Caching is automatic and on by default in every format. You don’t need to mark anything: unlike Anthropic’s API, a Messages request withoutcache_control is cached too.
- Per account. A request reuses only what earlier requests from the same account sent, from any of its keys. Other accounts’ prompts are never reused.
- In memory, for an hour. The cache holds a conversation so far, prompts and answers, in memory only. Nothing of it is written to disk. An entry is deleted 60 minutes after it was last used, and the cache can be emptied earlier, for example by a restart.
- Reported in usage. Cached input tokens are in
usage.prompt_tokens_details.cached_tokens(Chat Completions),cache_read_input_tokens(Messages) andinput_tokens_details.cached_tokens(Responses). cache_controlis accepted and ignored, andcache_creation_input_tokensis always 0.
Turn caching off
Turn caching off for a request with the body field or the header:
A request with caching off reuses nothing (its
cached_tokens is 0), and the cache keeps nothing of it: not its prompt, its answer or its token count. It is billed at the uncached rate. If caching can’t be turned off at that moment, such a request is answered 503 instead of being cached.
"in_memory", "24h" or no value keep the default (an entry still expires after 60 minutes). Any other value is answered 400. "prompt_cache_options": {"mode": "explicit"} also turns caching off; "implicit" leaves it on.
extra_body field or default_headers header.