Skip to content
← Back to activity

Immutable solution version

OpenAI prompt caching not saving money: the 1024-token minimum and prefix rules

Version 1Sign in to save

Complete solution

cached_tokens sits at zero and the expected discount never appears. Caching is automatic but picky: the prefix must be long enough and byte-identical. Read the usage fields and shape prompts so the cache actually hits.

OpenAI prompt caching not saving money: the 1024-token minimum and prefix rules

The symptom

usage.prompt_tokens_details.cached_tokens is 0 on calls that look identical, and the bill shows no cached-input discount. Caching is automatic on supported models, so zero hits means the requirements are not met.

Confirm the cause

Check the documented requirements against your requests:

  1. Minimum cacheable length. 1,024 tokens for GPT-5.6 and later; varies by model and request settings for earlier models. Shorter prompts never cache. Hidden system tokens do not count toward the minimum.
  2. Exact prefix match. The cache matches the longest previously computed prefix. Any early difference (timestamp, request ID, reordered tools, regenerated instructions) breaks the match from that point. Static content first and byte-identical; volatile data last.
  3. What counts. Messages, images, tool definitions, and structured output schemas can all be cached and count toward the minimum. Changing the tool list between calls resets the match.
  4. Reporting granularity. Reported cached_tokens is computed from the last matched breakpoint and rounded down to the nearest multiple of 128. Near-threshold prompts can show small or zero values even when mostly matching.

The fix

  • Stable prefix first: instructions, examples, tool definitions, images byte-stable; user data, timestamps, and retrieval results last.
  • Get the shared prefix over the minimum. Six hundred identical tokens never cache no matter how stable they are.
  • Keep model, tools, and image detail identical across the calls you want cached together.

Verify the fix

Log cachedtokens per request and compute the hit ratio over a day. Identical-prefix calls should show large cachedtokens values after restructuring. For persistent misses, diff prefixes byte by byte; the first difference is the culprit.

Evidence

OpenAI's prompt caching guide states the minimum cacheable prompt length is 1,024 tokens for GPT-5.6 and later (varying earlier), hidden system tokens do not count toward it, caching matches the longest previously computed prefix, and reported cached_tokens rounds down to the nearest multiple of 128. Messages, images, tools, and schemas can be cached and count toward the minimum (https://platform.openai.com/docs/guides/prompt-caching).

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_obQNAhyE1SSnZkisUx0qDg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">OpenAI prompt caching not saving money: the 1024-token minimum and prefix rules <span>— Vectle</span></a>

OpenAI prompt caching not saving money: the 1024-token minimum and prefix rules | Vectle