Skip to content
sinc-LLMBook a 15-minute call

How to Measure OpenAI Prompt Cache Coverage Before Rewriting a Prompt

Measure token-weighted cache coverage, isolate likely prefix and breakpoint issues, and check cost before changing the prompt.

On this page

By Mario Alexandre · November 29, 2026 · 3 min read

Measure the share of input tokens served as cache reads for one comparable group of OpenAI Responses API calls. Sum cached input tokens and divide by total input tokens. A low share is worth investigating when many requests repeatedly send the same eligible prefix. When most inputs are unique, estimate how much can actually be reused before you change the prompt.

Capture the two counts from each response

OpenAI recommends calculating the token cache-hit rate from total cached tokens divided by total input tokens for the selected group. OpenAI prompt caching guide

The OpenAI Responses API prompt-caching guide identifies usage.input_tokens_details.cached_tokens as the cached-token count and usage.input_tokens as the input-token count. OpenAI prompt caching guide

For each request, save an ID, model and configuration, route and prompt revision, time window, and both counts. Group calls where the workload and caching settings support the same comparison. Preserve responses with explicit zero cached tokens. When usage is unavailable, keep those requests in a separate missing-usage count. Report how many requests contributed to the calculation. Treat negative counts and cached counts above total input as invalid telemetry. Tally those separately and investigate the instrumentation before comparing revisions. If the contributing input total is zero, leave token coverage unavailable.

In an illustrative three-call group, the requests report 0 of 2,000, 1,024 of 1,500, and 1,024 of 4,500 input tokens cached. Across all three calls, coverage is 2,048 out of 8,000 tokens, or 25.6%. A dashboard counting requests that had any cache read would show two of three, about 66.7%. The token-weighted measure tells you how much input the cache served. The request-level measure tells you how often a call benefited at all.

Locate where the reusable prefix ends

OpenAI documents that cache reuse depends on a matching rendered prefix and that a change before a breakpoint prevents the longer prefix from matching. OpenAI prompt caching guide

Observation in a comparable group Check What to try
No cache reads across repeated calls Confirm usage, model-specific eligible length, breakpoint behavior, and request timing Use repeated synthetic calls with one fixed prefix and vary only the tail
Cache reads on short calls but low token coverage overall Compare the stable prefix with each request's full input and inspect long-tail calls Keep separate views for different input shapes
Coverage falls after a revision Compare where the rendered inputs first differ and review tool definitions and caching configuration Test a version that restores the prior shared section
Coverage rises but input spending rises too Inspect input size, cache-write usage where applicable, and the current model rates Compare total input cost on the same workload before adopting

A fixed document or schema can contribute to the prefix. An early timestamp, per-request identifier, or changed tool definition can interrupt it. Test with the actual model and request structure, because the current guide distinguishes cache breakpoints and minimum eligible lengths by model. Where supported, an explicit breakpoint at the end of a stable section is a candidate when the existing cache write extends through a changing suffix. OpenAI prompt caching guide

Keep the same sequence of sample inputs for the baseline and candidate, and record which call in each series creates or warms the reusable entry. Compare warm and cold calls in matching groups. A single successful warm read tells you that reuse can occur for that input. Your production decision depends on how often the same prefix can be read under a representative request mix.

Make the rollout decision on measured cost

For models with separate cache-write usage reporting, OpenAI says cached reads exclude tokens charged as cache writes. OpenAI prompt caching guide

Compare billed input categories using the rates for the tested model, with and without the proposed change. Track latency and output quality on the same cases. Keep the original layout if a rewrite introduces a regression or fails to lower the input cost you intended to change. Use the observed token counts as one input to your per-run AI workflow cost limits, alongside the other calls and retries the workflow can make.