← All articles

AI History

The 2024 discount that depended on the order of the prompt

Anthropic and OpenAI announced prompt caching weeks apart. Their launch figures left one variable in the hands of application developers.

The 2024 discount that depended on the order of the prompt

Ted Mavera, Product Manager at HarnessUp · November 24, 2026

The Beta Header

On August 14, 2024, a developer preparing a Claude API request could add a header called anthropic-beta and set its value to prompt-caching-2024-07-31. Inside the request, a long document could be placed before a question about it. If the next request began with the same document, Claude could resume from a prefix that had already been processed. Simon Willison recorded the beta header on the day of the rollout. Willison’s August 14 account · Claude API prompt caching documentation

The cost figure was easier to circulate than the arrangement of the request. Search Engine Journal reported that day that the feature could reduce costs by up to 90%. For teams sending lengthy material to Claude, the apparent opportunity was a lower price for input they already used. Search Engine Journal’s launch coverage

The price reduction depended on input being reused at the beginning of a request.

Consider an application that sends a policy manual to Claude with each question an employee submits. When the manual and the standing instructions are placed first, two requests can share a beginning even if one asks about expenses and the other asks about leave. A complete answer to the expenses question would be of little use on the second request. The processed manual, however, could be reused for both questions. Claude’s explanation of prefix reuse

The first day of integration work showed how that distinction affected library design. On August 14, an issue was opened in LangChain4j to add prompt caching to its Anthropic integration. The issue also mentioned Gemini and called for a design that could support both providers. The Java library would need a way for application developers to specify which part of a request could be cached. LangChain4j issue 1591

A Second Launch

On October 1, 2024, OpenAI introduced prompt caching in its API and announced a 50% discount on cached input tokens. Lower latency was also cited in the announcement. With a second provider publishing a price for reused input, an application’s input bill could be assessed in terms of the material processed for each request and the material eligible for reuse. OpenAI’s October 1 announcement

The two percentages described launch offers under different terms. The August coverage gave an upper bound for Claude. OpenAI’s October figure applied to cached input tokens. To estimate the effect on a bill, a team still needed to know how much of the input would qualify and how much of the bill was allocated to input in the first place. August coverage of Anthropic · OpenAI’s launch terms

OpenAI stated its October discount per cached input token.

For a hypothetical request, take 8000 input tokens billed at the same base rate, with 6000 served from the cache. Under the October discount, the cached portion would cost the equivalent of 3000 full-price input tokens. With the other 2000 added at full price, the input charge would be equivalent to 5000 tokens, a 37.5% reduction. Any output charge would be accounted for separately. OpenAI’s historical cached-input discount

The October discount percentage alone does not show how much an application would save by repeatedly sending the same manual compared with sending a different document on each call. The manual can be processed once and reused if requests share that prefix and the cache is available. Requests with different documents contain less repeated input eligible for the discount. OpenAI API prompt caching guide

Where Reuse Breaks

Return to the Claude request with the policy manual. Suppose the application puts the employee’s question before the manual because its request template was written to display the question first. When the question changes, the two requests diverge at that point. The identical manual is still transmitted, but it sits after the divergence and falls outside the beginning shared by the two requests. Claude documentation on cached prefixes

Even when the manual is placed early, headings generated by the application can limit reuse. A request ID or a timestamp inserted before the manual would change the beginning on each call. Where the application can place that changing information after the manual, the shared portion can extend through the document. The difference can be seen in the assembled request, down to the line where the ID is inserted.

The same document can appear outside the shared prefix.

Some changes to the beginning are required by the work. If two departments operate under different reimbursement rules, each version must be sent to the employees it applies to. Once a revised version is issued, a request containing it will diverge from an earlier version at the first amended passage. Any reusable portion ahead of the amendment depends on how the request was assembled and what is available in the cache.

The same constraint applies to a coding agent that reads a file, edits it and then reads it again. If the updated file is supplied as input, the model needs the new text for the next decision. A long block of standing instructions can still be shared at the start of those requests if it was placed there. The file contents belong to the part of the request that reflects the current state of the work.

The Rest of the Bill

Once repeated input has been identified, the expense of sending and generating other material remains visible. A coding agent may be given the same repository instructions on several calls, then generate a patch or explanation for the immediate task. The repository instructions may qualify for cached-input pricing. The patch is generated for that call, and its output tokens are outside the discount announced by OpenAI in October. OpenAI’s description of the discounted input

A request can use the cache even if it contains more input than the task requires.

In a coding session, a tool may return a full build log when the next decision depends on one compiler error. If the log is sent again as part of a shared prefix, some of the cost of processing it may be reduced. If the application sends only the relevant excerpt, fewer tokens are submitted in the first place. The two changes can be assessed from different quantities, the cached portion of the input and the amount of input sent.

Latency has a similar boundary. Anthropic’s documentation describes savings in processing time when a prompt prefix can be reused. If a coding agent spends much of the session waiting for a test command or generating a long patch, the time saved on the reused prefix is only one part of the duration. A faster response to a repeated manual and a faster end-to-end coding task are separate measurements. Claude documentation on processing time

HarnessUp’s “Deep Scan” examines conversations saved on the user’s machine and shows where context was used. For a Claude Code or Codex session, the record shows how much material the agent received during the session. The August and October announcements described how the API providers processed repeated input. HarnessUp’s local tools for measuring and reducing token use in Claude Code and Codex

The Request Record

For an application that revises its prompt template, the two versions can be compared using the same manual and the same set of questions. If the question is moved from before the manual to after it, the shared beginning will be longer in the revised version. The relevant evidence is the cached input reported across successive requests, with the total input and output recorded alongside it. Otherwise, a shorter answer could be mistaken for a saving on the manual. OpenAI’s guide to prompt caching and usage

The comparison uses the request as the application sent it.

A source template may show the manual above the question, while the application inserts a changing value ahead of both when it assembles the request. In a comparison for the policy manual, the date or request ID belongs beside the manual on the request record. The first line that differs between two requests establishes how far the common beginning extends.

Side-by-side Claude API requests showing a policy manual within the shared prefix when the request ID follows it, and outside the shared prefix when the ID comes first.

If the same question set is used on a day when the policy manual has been amended, the version sent with each request should also be recorded. Two calls can reach the same model with the same title on the manual and different text in the reimbursement section. The source of the divergence is then a policy revision, while a divergence at an inserted request ID can be traced to the template or request assembly.

On August 14, 2024, Willison recorded the header required to use Anthropic’s Claude API beta. Claude’s documentation describes reuse from a specific prefix in the input, which in the policy example is the beginning of the assembled request shared by the two questions. The header was separate from the manual. Willison’s launch-day account · Claude’s documentation on prompt prefixes

This article was drafted with AI assistance in HarnessUp Publish and approved by the HarnessUp team before publishing.