Opens in a new tab
Guide

Follow the prompt-cache saving all the way to the bill

In brief

Start with a request that cannot reuse earlier work, then follow the warm requests, retries and missing charges. A provider-neutral trial and local Python ledger show what the saving bought: handoffs a reviewer can accept.

9 min read

Is this the right starting point?
Before you read
Practical model-API integration and evaluation experience, including usage accounting; basic Python and command-line use for the optional calculator.
What you will take away
Design a controlled prompt-cache pilot with provider-specific charge reconciliation, stable acceptance criteria and complete attempt accounting.
Sources
Three ivory strips share one cobalt embossed beginning and end in different apricot inserts beyond a visible join.
On this page6 sections

A responder adds the latest incident update and asks the assistant for a handoff. A few minutes later, another update arrives. The service reference and response instructions are still the same, yet the assistant receives them all over again. There is work worth reusing here. Prompt caching saves some of the model's computation on that repeated beginning, while leaving it to handle the new material and write a new answer.

The responder, though, is waiting for a usable handoff, not a cheaper request in isolation. Finding the source material, failed attempts, retries and review all belong to that job's cost. Our guide to AI token usage develops that whole-task view. This proposed read-only pilot puts it to work on two questions that can otherwise drift apart: what did reuse save, and what did the reviewer actually accept?

Keep the familiar beginning and change the news

Consider those two updates side by side. If their beginnings match, the model may reuse saved intermediate calculations for that prefix, the unchanged opening of the request. It is not retrieving yesterday's answer. OpenAI’s prompt-caching documentation describes the saved calculations as key-value tensors, numerical arrays the model uses to refer back to earlier input. New material still has to be processed and a new response generated. The rendered prefix must match; sharing a conversation session does not guarantee that it will.

Now put the current timestamp ahead of the instructions. The next update changes it, and the match can stop before the useful repeated material begins. Nothing important about the service reference changed, but its position after the changing timestamp matters. The cache follows the actual request, not our sense that the two conversations are about the same incident.

One possible layout keeps approved instructions, tool definitions and the selected version of the service reference at the front. The incident question and fresh observations follow in the changing suffix, or remainder. That is an application design to evaluate, not a format every provider shares. Moving material around must preserve message roles and instruction priority. A saving that changes which instruction governs the task is a different experiment.

The reference also needs a version worth reusing. Select the current approved service reference before assembling the request. A deployment snapshot that changes every minute belongs with the fresh incident material instead. Otherwise the assistant can become very efficient at reading an inventory that no longer describes the service the responder is trying to fix.

A versioned stable prefix and fresh task evidence enter each request. Every attempt feeds a cost ledger, while independent review determines whether the task is accepted. Both feed the rollout decision.
Proposed handoff pilot: record cache use and the cost of every attempt, then independently review the finished task. Reuse explains spending; acceptance says whether the spending produced usable work.

Read the handoff before celebrating the bill

What would let the next responder take over? The affected service needs to be clear, the unresolved questions need to remain visible, and observations must support any claim of recovery. Give both configurations that same review standard. If the cheaper version gets a more forgiving reader, the comparison has already changed.

Here is a hypothetical result, not a provider price or a measured model benchmark. Each configuration receives 100 tasks. The baseline spends $12 and produces 80 accepted handoffs, or $0.15 each. The caching candidate spends $8 but produces only 40 accepted handoffs, or $0.20 each. The smaller bill buys usable results at a higher price. That is easy to miss if the report stops at total spending.

The arithmetic does not tell us why acceptance fell. Perhaps the prompt changed, the model changed, or the candidate received different source material. Keep those steady and read the rejected handoffs before assigning the cache either credit or blame.

One handoff can also have several bills. A failed attempt followed by a successful retry costs both amounts, while the accepted result counts once. Record reviewer minutes alongside the spending. Converting that time to dollars takes an explicit labor-cost assumption; the token bill, which charges for pieces of model input and output, cannot price a person's time for us.

Let the awkward updates into the trial

A useful trial includes the update that is hard to summarize: two conflicting timestamps, a missing observation, a newly approved reference, or recovery that nobody has checked yet. Use synthetic or appropriately sanitized material so the comparison does not collect unnecessary sensitive content. Give each task a stable identifier. That is how an abandoned attempt can still find its place in the account later.

For each task, both configurations need the same observations. Keep and record the model identifier, endpoint, prompt and source-document versions, tools, generation settings and review standard. Then a change in the answer has a chance of being attributable to the configuration under test, rather than a newer fact quietly arriving in only one version.

Include the first request, before reuse may be available. Some providers cache automatically, so a column labeled baseline does not necessarily mean uncached. Where a documented control exists, use it to establish the intended condition. Otherwise distinguish observed cold requests, with no reused state, from warm requests in the usage records. Naming the column cannot set the service's behavior.

Follow with another eligible prefix and different incident material at a realistic interval. Extra requests sent just to warm the cache count too, including their purpose and cost. Then change the approved reference version or tool schema, and try again beyond the documented retention period. The assistant still owes the responder a current handoff when the repeated work cannot be reused.

At review, the task identifier brings the attempts back together. Attach spending, rejection reasons, reviewer minutes, time to the first response and time to completion. The responder who got a quick answer and then had to request a correction experienced a different wait from the one whose first answer was usable.

The clock outside the experiment matters as well. Running the baseline during quiet hours and the candidate at peak demand mixes that difference into the response-time comparison. Interleave or randomize their order where practical. Keep timeouts and missing responses as rows, and bound the pilot with a request limit and spending ceiling. A small sample can uncover broken accounting or a missed constraint, but it cannot characterize rare slow requests well. A spreadsheet's percentile function, which picks a position among ordered results, does not create the missing observations. Read the failed and delayed handoffs before using a neat summary to justify expansion.

Three input counts are not three versions of the same charge

The bill can be as easy to misread as the incident update. Anthropic reports cache_creation_input_tokens, cache_read_input_tokens and input_tokens. The last counts input outside the cache-read and cache-write portions. In a hypothetical row with 100 ordinary input tokens, 200 creation tokens and 700 read tokens, the total is 1,000. These are illustrative counts, not collected usage or dollar charges. Add the three fields; do not subtract cached tokens from the ordinary field again. Anthropic’s usage definitions give the adapter, the code translating a response into the ledger's format, that essential distinction.

Changing providers brings another difference. The Gemini caching guide separates implicit reuse, handled by the service, from explicit cache objects the application manages. The Interactions API supports implicit caching. Explicit objects are available through generateContent for supported Gemini 3 and 2.5 models, not Gemini 4 Argon and later models. Follow the actual endpoint: the shared word caching does not promise the same controls.

Even our 1,000-token example still lacks a dollar figure. Retain the provider response and translate its usage into non-overlapping charge categories with rates for the actual model, tier and region. Add applicable retention, storage and tool charges. OpenAI's documented cache-write rate replaces the ordinary input rate for those tokens; it is not another charge on top. Counting both would manufacture a cost before any comparison began.

Reconcile a small ledger with provider billing before widening the workflow. A cache-read count tells us what happened, but not necessarily what it cost. A timeout with no usage returned leaves an unknown charge, not a free request. Keep the price snapshot and calculation version with the result so a later rate change does not silently alter the old comparison.

Give the missing bill a place in the calculator

The Python ledger calculator and illustrative sample ledger perform a narrower, local job: arithmetic on already-normalized USD charges. They use Python's standard library without network calls. They neither fetch prices nor decide whether the handoff deserves acceptance. Run them on the supplied sample to see how an incomplete account differs from a zero-cost task:

python3 prompt-cache-ledger.py prompt-cache-sample.json

Suppose review accepts the second attempt. The task has one final true-or-false acceptance decision and two attempts, each with a unique identifier and attributable charge, including measured tool costs. A missing first bill is null, not an omitted attempt. Put shared cache preparation or storage once in group-level overhead instead of charging it again to each handoff. Reviewer minutes remain separate from those dollar amounts.

The sample's baseline and candidate reproduce $0.15 and $0.20 per accepted handoff. A third group has a missing charge: its known subtotal is available, but cost per accepted result is null. A group with no accepted tasks also has an undefined result, not a miraculous zero cost per success. The calculator leaves the answer open where the account cannot support one.

It cannot notice an attempt that never made it into the input at all. Match the attempt identifiers to source records, including failed or abandoned tasks. That reconciliation does not require sensitive prompts in the cost ledger. Identifiers and charges serve the accounting; supporting material can stay under its existing access and retention controls, linked for review where needed.

Keep the saving only where the handoff benefits

An overnight summary can tolerate a wait that would frustrate someone responding to an active incident. Judge the result against that actual need: usable content, acceptable waiting time and spending. A high cache-hit rate cannot decide those on the responder's behalf.

If reviewers cannot decide acceptance repeatably, cost per accepted task is not yet a sound reason to expand. Keep the work exploratory, reporting findings and review effort until there is a suitable outcome measure. And if ordinary prefixes seldom repeat within the usable retention window, simpler assembly may be the better choice. Manufacturing repetition would make the trial look nicer while answering a question the workflow did not ask.

A promising result can move to a bounded share of eligible read-only work. Keep the earlier prompt assembly and cache configuration available for reversal, but continue using current observations and preserve tool restrictions. Reverting should not revive an obsolete service reference. A change in model, policy or schema also calls for another behavior check before carrying the earlier result forward.

Now place the two handoffs beside the bill again. The repeated beginning may have become cheaper, but the fresh update still had to reach the model and the reviewer still had to accept the answer. The first cold request, the retry and the revised reference all have a place in the account. The agent evaluation guide develops the review decision further. Keep the cache where that complete job improves. Where the work rarely repeats, let the simpler request do its job.

Sources & context

Sources linked in this article. Read alongside the author’s analysis; a citation does not independently verify a publisher’s claims.

Report an error or outdated detail

More on OpenAI

All OpenAI coverage

Keep reading

Where to go next