Skip to content
GUIDES#prompt caching#OpenAI API#token cost

Prompt Caching on OpenAI: How to Cut Token Costs When Every Call Sends the Same Context

Twenty thousand tokens of taxonomy, a thousand calls a day, and the same text sent over and over. It looks like a cost problem, but in most cases it is a structure problem: where the text sits in the prompt, and whether it stays identical from call to call.

Yaakov Tzedek
Yaakov Tzedek · AI expert·9 min read
THE BOTTOM LINE
  • How to reduce OpenAI API token costs when every call sends a long taxonomy: prompt structure that hits the cache, current pricing, and when to switch to RAG instead.

If every API call sends the same long taxonomy, the solution is not to stop sending it. The solution is to always send it in the same place and in the same form: at the top of the prompt, before anything that changes. That way OpenAI caches it (Prompt Caching), and with GPT-6.1 Sol every repeated read of it costs 5% of the regular input price. When the taxonomy is too large, or when each question needs only a small part of it, you switch to retrieval (RAG) and send only what is relevant.

Twenty thousand tokens of taxonomy, a thousand calls a day, the same text sent over and over. It looks like a cost problem, but in most cases it is a structure problem.

The question came from an AI group on Facebook: a developer who built a system for his own business, tried several providers, and found that a Custom GPT worked best for him. The problem: every conversation requires sending a large, repeating taxonomy upfront, and once the system scales the bill will be too high. Uploading to the Files API did not help, because reading from there also counts as tokens. This guide answers that question, step by step.

In short

QuestionShort answer
What saves money?A fixed, identical prefix on every call, stored in OpenAI's cache
How much does it save on GPT-6.1 Sol?A cache read costs $0.10 per million tokens, instead of $2
What is the cost?The first cache write costs 25% more than regular input
Why did the Files API not help?The file content is still read as input, regardless of where it is stored
When to use RAG?When the taxonomy is huge and each question needs only a small part of it
How do you verify it is working?The cached_tokens field in the API response

First: where does the cost actually come from?

Before changing any architecture, it is worth confirming that you are paying per token at all. According to OpenAI's Help Center (checked 2026-10-13), ChatGPT and the API platform have separate billing systems. A GPT running inside ChatGPT does not generate a per-token invoice on the API platform. Per-token costs arise when your code calls the API directly, for example a server behind a GPT Action, or a system running outside ChatGPT.

One more point that affects planning: OpenAI announced it plans to deprecate Custom GPTs and recommends migrating workflows to Plugins. According to that same page (checked 2026-10-13), for Enterprise environments affected by the change, deprecation is planned for December 11, 2026, and dates are subject to change. Anyone building a long-term system should put the expensive logic on the API side, and that is exactly where caching comes in. I summarized what is new in the models themselves in my OpenAI DevDay 2026 announcements summary.

How Prompt Caching works in OpenAI

OpenAI stores the computed result of the beginning of a prompt, and if the next call starts with exactly the same text, it does not recompute it. According to the official Prompt Caching guide (checked 2026-10-13), the mechanism works by default on supported models and can reduce input costs by up to 95% and cut time-to-first-token.

These are the key rules to know:

  • Full prefix match. Everything before the breakpoint must be identical. Changing a single character early in the prompt invalidates reuse for everything that follows.
  • Minimum length. On GPT-5.6 and above, the prefix must contain at least 1,024 visible tokens.
  • What goes into the cache: instructions, system messages, tool definitions, and conversation history including text, images, and documents.
  • Lifetime. On GPT-5.6 and above, a prefix stays available for at least 30 minutes from the last use or last write. There is no way to manually clear the cache.
  • Rate limits. Cached tokens still count toward the tokens-per-minute limit.

GPT-6.1 Sol pricing

According to OpenAI's pricing page (checked 2026-10-13), at Standard pricing and contexts up to 272,000 tokens:

Token typePrice per million tokensRelative to regular input
Regular input$2100%
Cache write$2.50125%
Cache read$0.105%
Output$10Not relevant to cache

On models from GPT-5.6 and above, a write costs 1.25x regular input and a read costs one-tenth of it. GPT-6.1 Sol is the generous exception: a read costs only 5%. On earlier models there is no surcharge for writing, and the discount rate varies by model. A full comparison of the model against Astra is in my GPT-6.1 Sol guide.

How much it saves: a sample calculation

This is an illustrative calculation, not a real client case. Assume a 20,000-token taxonomy sent with every call to GPT-6.1 Sol, across one thousand calls:

ScenarioCalculationTaxonomy cost
Without cache1,000 calls x $0.04$40
With cache, always warmOne write at $0.05, plus 999 reads x $0.002~$2.05

In practice there will be a few additional writes, because the cache lives on specific machines and expires after inactivity, so the real number will be slightly higher. The simple math worth remembering: one write plus one read costs 130% of the input price, compared to 200% for two reads without a cache. The prefix pays off on the second use.

How to structure the prompt so it enters the cache

  1. Order the prompt from fixed to variable. System instructions first, then the taxonomy, then tool definitions, and only at the end the user's question. Everything that changes (date, customer name, session ID) goes to the bottom.
  2. Freeze the wording. The taxonomy is loaded from a single versioned file, in the same order and the same format every time. Reordering JSON fields or adding an extra space breaks the match.
  3. Mark an explicit breakpoint after the taxonomy. On models from GPT-5.6 and above, in default mode the breakpoint is set at the end of the last message, so even the variable part may be written to the cache at the write price. In explicit mode you define exactly where the cache ends:
{
  "model": "gpt-6.1-sol",
  "prompt_cache_options": { "mode": "explicit" },
  "prompt_cache_key": "taxonomy_v3:customer_123",
  "input": [
    {
      "role": "developer",
      "content": [
        {
          "type": "input_text",
          "text": "Fixed instructions + full taxonomy, version 3",
          "prompt_cache_breakpoint": { "mode": "explicit" }
        }
      ]
    },
    { "role": "user", "content": "The user's question" }
  ]
}
  1. Use prompt_cache_key. On GPT-5.6 and above it separates cache accounting by customer, user, or workspace, and helps prevent attempts to probe what is in someone else's cache. On earlier models it improves routing, and the documentation recommends around 15 requests per minute per key.
  2. Prewarm when needed. Setting "prewarm": true inside prompt_cache_options prepares the cache without generating output. This write is billed at the regular write price, so it is only worth doing when traffic is certain to follow.
  3. Measure. Every response returns usage.input_tokens_details.cached_tokens and cache_write_tokens. If cached_tokens stays at zero, something in the prefix is changing.

Why the Files API did not solve the problem

Because the problem was never where the text is stored, but how many times the model computes it. A file attached to a request is read by the model, and its content counts as input tokens exactly like pasted text. The cache does not reduce the number of tokens; it reduces the price of tokens that repeat.

The File Search tool is not free either. According to the pricing page (checked 2026-10-13), it costs $2.50 per thousand tool calls, and vector storage costs $0.10 per GB per day, with the first GB free. According to the File Search guide, limiting the number of results (max_num_results) reduces token usage and response time, at a possible cost to quality.

When to switch to retrieval (RAG) instead of sending everything

Caching makes repeated text cheaper. Retrieval prevents sending text that is not needed. These are two different problems, and the decision comes down to one question: how much of the taxonomy does each question actually need?

SituationRecommended approachWhy
Taxonomy of a few thousand tokens, most of it relevant to every questionCache onlySimple, cheap, and the model sees the full picture
Taxonomy of hundreds of thousands of tokens, each question needs a few itemsRetrievalSend ten items instead of thousands
Long fixed instructions and a large item databaseCombinationInstructions and classification rules in cache, relevant items via retrieval
Over 272,000 tokens per callSeriously consider retrievalThe per-token price in long context doubles, per the pricing page

Note a subtle point about the combination approach: retrieval results change from call to call, so they must sit after the breakpoint. If they appear before the fixed instructions, they invalidate the cache for everything that follows.

Another question worth asking: does the taxonomy actually need to be in the prompt? Sometimes you can give the model a tool that looks up a category by name, and send only the top-level hierarchy in the prompt. This principle, giving an agent tools instead of overloading it with context, is covered in detail in my guide to building an AI agent for a business.

Three more ways to lower the bill

  • Compress the taxonomy itself. The person asking mentioned that it "repeats itself." Short identifiers instead of full names, removing duplicates, and using a table format instead of verbose JSON shrink the prefix even before the cache.
  • Batch what is not urgent. According to the pricing page, in Batch mode GPT-6.1 Sol input costs $1 and output costs $5 per million tokens, roughly half the Standard price. Good for overnight classification of thousands of records.
  • Flex. On the same page, in Flex mode GPT-6.1 Sol input costs $1, cached input costs $0.05, and output costs $5. And in the other direction, anyone considering Ultrafast will pay six times the Standard price, as I detailed in my OpenAI Ultrafast guide.

Mistakes That Reset the Cache

  • Date or time in the system instructions. The most common mistake. Put the date at the end of the prompt.
  • The user's name in the first line. "Hello Dana, you are helping..." turns every user into a separate cache.
  • Removing tools between calls. The documentation recommends keeping tool definitions stable and using tool_choice: "none" or allowed_tools instead of deleting tools.
  • Summarizing or condensing conversation history. Any rewriting of the history resets reuse. Add messages, don't rewrite them.
  • A small taxonomy update in the middle of the day. Every new version starts the cache from zero. Consolidate updates into a single window.

The Bottom Line

Back to the taxonomy being sent a thousand times a day. It never needed to move to the Files API, and it doesn't necessarily need a complex retrieval system. In most cases it needs to sit at the beginning of the prompt, in exactly the same wording, with a breakpoint after it. The order is the saving.

Three steps for the coming week: sort the prompt from fixed to variable, check cached_tokens in the first ten calls, and only if the taxonomy is too large to send in full, build a retrieval layer that completes the cache rather than replacing it.

Want a deep dive into GPT-6.1 Sol and Ultrafast before choosing a model for your system? There is an interactive course for 9.90 ILS: GPT-6.1 Sol and Ultrafast 2026, the new OpenAI models for developers and businesses.

Sources

Frequently asked questions

Was this article helpful?
Share:WhatsAppLinkedInX
Yaakov Tzedek
WRITTEN BY

Yaakov Tzedek

An Israeli AI lecturer, consultant and implementer who has supported 100+ organizations in AI implementation and lectured for 200+. Official content partner of Meta, Google, Canva and TikTok, featured on Israel's Channel 13.

More about Yaakov →