OpenAI prompt caching: automatic prefix caching above 1024 tokens
Answer: OpenAI prompt caching turns on automatically for prompts longer than 1024 tokens, with no change to the request. The system checks whether the beginning portion (prefix) of the prompt has already been cached.
How to get hits
- Static content (instructions, examples) goes at the beginning of the prompt; variable content goes at the end.
- Tools and images must be identical, even in their ordering, between requests.
- For multi-turn chats, append new elements to the end of the messages array.
- Check
cached_tokensinusage.prompt_tokens_details; for requests under 1024 tokens it is zero.
Same idea on vLLM
vLLM Automatic Prefix Caching reuses the KV cache when a new query shares the same prefix with an existing query. Enable it with enable_prefix_caching=True. APC only reduces the prefilling phase and does not reduce the time of generating new tokens.
See also
Claims
- id: C1 claim: Caching activates above 1024 tokens. source: S1 evidence: "Prompt caching automatically activates for prompts longer than 1024 tokens"
- id: C2 claim: Tools must match in order. source: S1 evidence: "must be identical even in their ordering between requests"
- id: C3 claim: APC does not speed decoding. source: S2 evidence: "does not reduce the time of generating new tokens"
Sources
- [S1] Prompt Caching 101. openai/openai-cookbook (GitHub). https://github.com/openai/openai-cookbook/blob/main/examples/Prompt_Caching101.ipynb . License: MIT. Accessed 2026-11-16.
- [S2] Automatic prefix caching (vLLM docs). vllm-project/vllm (GitHub). https://github.com/vllm-project/vllm/blob/main/docs/features/automatic_prefix_caching.md . License: Apache-2.0. Accessed 2026-11-16.
License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: openai/openai-cookbook (GitHub), Prompt Caching 101, MIT (https://raw.githubusercontent.com/openai/openai-cookbook/main/LICENSE). Copyright (c) 2025 OpenAI; vllm-project/vllm (GitHub), Automatic prefix caching (vLLM docs), Apache-2.0 (https://raw.githubusercontent.com/vllm-project/vllm/main/LICENSE). Text was condensed and changed from the originals.
License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: openai/openai-cookbook (GitHub), Prompt Caching 101, MIT (https://raw.githubusercontent.com/openai/openai-cookbook/main/LICENSE). Copyright (c) 2025 OpenAI; vllm-project/vllm (GitHub), Automatic prefix caching (vLLM docs), Apache-2.0 (https://raw.githubusercontent.com/vllm-project/vllm/main/LICENSE).
Cite this
iinventedlight. 2026. "OpenAI prompt caching: automatic prefix caching above 1024 tokens." iinventedlight Library, iil:note:xm9k5v9d, version of 2026-11-16. https://iinventedlight.com/library/notes/ao-caching-openai-automatic-prompt-caching/. License: CC-BY-4.0.
@misc{iil_note_xm9k5v9d,
author = {{iinventedlight}},
title = {{OpenAI prompt caching: automatic prefix caching above 1024 tokens}},
howpublished = {iinventedlight Library},
year = {2026},
date = {2026-11-16},
url = {https://iinventedlight.com/library/notes/ao-caching-openai-automatic-prompt-caching/},
note = {Permanent ID iil:note:xm9k5v9d. License: CC-BY-4.0.},
}
Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).
For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/ao-caching-openai-automatic-prompt-caching.md.