guides/prompt-caching.md +28 −0
8 8
9This guide describes how Prompt Caching works in detail, so that you can optimize your prompts for lower latency and cost.9This guide describes how Prompt Caching works in detail, so that you can optimize your prompts for lower latency and cost.
10 10
11## Caching behavior changes when migrating to GPT-5.6
12
13GPT-5.6 models and later model families cache exact prompt prefixes at cache
14breakpoints. By default, the service places an implicit breakpoint at the latest
15user or tool message. Unlike earlier models, it does not automatically fall
16back to the longest matching unmarked prefix before that breakpoint.
17
18For example, requests might share 4,000 tokens of instructions and other static
19content, followed by changing timestamps, tool-call history, or user input. If
20the implicit breakpoint includes that changing content, the full prefix at the
21breakpoint differs between requests. As a result, `cached_tokens` can be `0`
22even though the requests share thousands of identical tokens, and the service
23can repeatedly write the changing prefix to cache.
24
25To reuse the shared content, add an explicit `prompt_cache_breakpoint` at the
26end of the stable prefix and set the same `prompt_cache_key` on requests that
27share it. Content after the breakpoint can then change without invalidating the
28cached prefix.
29
30To avoid cache-write charges for the changing suffix, set
31`prompt_cache_options.mode` to `explicit`. This disables the implicit
32breakpoint, so only your explicit breakpoints are eligible for cache reads and
33writes. On GPT-5.6 models and later model families, cache writes cost 1.25× the
34uncached input token rate, so caching only the reusable prefix can reduce costs.
35
36See [Prompt cache breakpoints](#prompt-cache-breakpoints) for request examples,
37supported content blocks, and cache policy options.
38
11## Structuring prompts39## Structuring prompts
12 40
13Cache hits are only possible for exact prefix matches within a prompt. To realize caching benefits, place static content like instructions and examples at the beginning of your prompt, and put variable content, such as user-specific information, at the end. This also applies to images and tools, which must be identical between requests.41Cache hits are only possible for exact prefix matches within a prompt. To realize caching benefits, place static content like instructions and examples at the beginning of your prompt, and put variable content, such as user-specific information, at the end. This also applies to images and tools, which must be identical between requests.