---
source: https://iinventedlight.com/library/notes/ao-caching-openai-automatic-prompt-caching.md
title: "OpenAI prompt caching: automatic prefix caching above 1024 tokens"
license: CC-BY-4.0
license_url: https://creativecommons.org/licenses/by/4.0/
source_license: "MIT (openai/openai-cookbook (GitHub)); Apache-2.0 (vllm-project/vllm (GitHub)); prose restates cited source lines in own words"
license_family: mixed-green
attribution: "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)."
author: "iinventedlight (synthesis of cited sources); text drafted with AI assistance"
date: 2026-11-16
status: published
approved_by: "Cole Withington, 2026-11-20 13:14 PT: \"Publish the full batch and rewrite the 6 live notes\""
checked_on: 2026-11-16
as_of: 2026-11-16
confidence: medium
untested: "Not reproduced (2026-11-16). Docs read; no API call was made for this note."
category: agent-operations
topic_area: "agent operations: prompt caching"
tags: [prompt-caching, openai, cached-tokens, prefix, vllm]
client: Librarian
sources:
  - id: S1
    title: "Prompt Caching 101"
    publisher: openai/openai-cookbook (GitHub)
    url: https://github.com/openai/openai-cookbook/blob/main/examples/Prompt_Caching101.ipynb
    accessed: 2026-11-16
    license: "MIT"
  - id: S2
    title: "Automatic prefix caching (vLLM docs)"
    publisher: vllm-project/vllm (GitHub)
    url: https://github.com/vllm-project/vllm/blob/main/docs/features/automatic_prefix_caching.md
    accessed: 2026-11-16
    license: "Apache-2.0"
---
# 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_tokens` in `usage.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

- [ao-caching-anthropic-cache-control](https://iinventedlight.com/library/notes/ao-caching-anthropic-cache-control/)
- [ao-caching-gemini-context-caching](https://iinventedlight.com/library/notes/ao-caching-gemini-context-caching/)
- [ao-cost-token-usage-tracking](https://iinventedlight.com/library/notes/ao-cost-token-usage-tracking/)

## 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.

---

Agents: [/agents.md](/agents.md) | [/.well-known/agent-library.json](/.well-known/agent-library.json).
