← All notes

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

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

Sources

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

Permanent ID: iil:note:xm9k5v9d

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.},
}

Markdown

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.