Written by the Miracuves Editorial Team. Reviewed by Aditya Bhimrajka, Founder & CEO, Miracuves.
Key Takeaways
- Prompt caching and semantic caching cut different parts of the bill. A prompt cache makes repeated input cheaper on calls that still run. A semantic cache skips the call entirely when a stored answer is valid for the new request.
- Prompt caching alone leaves output costs untouched. In the worked example below, where output is half the bill, prompt caching saves 27% and safe answer reuse does the rest.
- Read cached tokens from the provider’s usage fields, not hit counts. OpenAI reports cached tokens inside the input count, Anthropic reports them outside it, and cache writes can cost more than ordinary input.
- Similarity is a ranking signal, not permission to reuse. Partition by tenant and permission first, then check plan, dates, amounts, negation and policy version before serving any stored answer.
- Judge the result per successful resolution. A cheap wrong answer that brings the customer back costs more than the call it replaced.
Your AI support assistant answers in one short sentence, yet the invoice says each conversation sent thousands of tokens to the model. Most of them were never visible: a system prompt, tool schemas, policy excerpts, examples and chat history, sent again for the next customer who asks nearly the same thing.
This guide is for the product or engineering lead who owns that bill and wants to know two things: which kind of caching fits the workload, and how much it can honestly save. By the end you should be able to place each cache in the request path, calculate the saving in billing terms and tell whether a 70% reduction is realistic for your traffic or only for a worked example.
Two layers do the work. Prompt caching lets the model provider reuse computation for an identical beginning of the input, but the model still writes a fresh answer. Semantic caching is something your application does: it returns a previously approved answer to an equivalent request without calling the model at all. The first makes some calls cheaper. The second removes some calls from the bill.
The 70% figure is the outcome of the scenario worked through below, not a typical result. It depends on long repeated input, a high rate of safe answer reuse and modest cache running costs. An application that writes original material, reads live records or takes actions for individual users will land somewhere else.
Where the Tokens on Your Invoice Actually Go

Split every call into what the model reads and what it writes. Input includes invisible instructions and machine-readable tool schemas as well as the user’s text. Output includes the answer, any structured fields and model-generated tool arguments. The chat transcript is not a billing record. The provider’s usage fields are.
One customer question, four model calls
A customer asks, “Can I return shoes I bought on sale?” The application classifies the intent, rewrites the query for search, retrieves the store’s return policies and calls the model to compose a reply, the four steps in the diagram above. If the reply fails a format check, it calls the model again. The customer sees one answer. Finance sees several requests plus retrieval and infrastructure.
Draw that path before choosing a cache. A semantic hit placed after retrieval does not save retrieval. A hit placed before the whole workflow can save several calls, but only if no account check or permission step is skipped along the way. A prompt-cache hit inside the final reply call does nothing for the classifier call before it.
Build a baseline you can reconcile with the invoice
Log one record per model call with the feature, workflow step, model, total input, cached input, cache writes, output, retries and whether the customer’s task was resolved. Group by route, not by model: a checkout FAQ and a long-form writing feature can share a model and have completely different reuse potential. Use a full billing cycle, and mark launches, migrations and promotions that would distort it.
Watch how each provider counts cached tokens, because this is where most savings reports go wrong. OpenAI’s Responses API reports them as a detail inside the input count, in usage.input_tokens_details.cached_tokens. Anthropic reports input_tokens as only the tokens after the last cache breakpoint, with cache reads and cache writes in separate fields that you add back to get the total. Apply OpenAI’s ordinary input rate to the full input count and add the cached tokens again, and you have billed them twice.
Keep the generation bill separate from the cost of running the feature. Embeddings, a vector index, replicas, network traffic, monitoring and human review all belong in the net calculation. The AI app infrastructure and API cost breakdown puts token charges next to those other running costs. Everything in this guide is measured against one workload’s generation and caching spend, not the whole application.
Prompt Caching, Exact Caching and Semantic Caching Compared
A prompt cache works on the start of the rendered input. If the opening tokens match a recent request exactly, the provider reuses the work it already did on them and charges a lower rate. No earlier answer comes back. The call runs, new input is processed at the normal rate and output is billed in full.
A semantic cache asks a different question: is a stored answer valid for this request? “Can I export a CSV?” and “Is CSV export available?” are the same question on the same plan and product version. If that holds and the stored answer is approved, the application skips generation. If not, the request takes the normal path.
Between them sits the exact response cache, which serves a saved answer when a strict key matches. If a help-center button always sends the same canonical request, a plain key lookup is faster and cheaper than embedding the text. Similarity search earns its cost only when real variation in wording defeats a strict key.
| Cache layer | What can match | What it can save | Main check |
|---|---|---|---|
| Prompt cache | An identical input prefix above the provider’s minimum length | Part of the input charge and some time to first token | Cached token counts in usage data, plus any cache-write premium |
| Exact response cache | A strict application key | The model call and any work the hit bypasses | Key includes scope, versions and every input that changes the answer |
| Semantic response cache | An equivalent request with a valid stored answer | The model call and any work the hit bypasses | Permissions, policy version, decisive facts and freshness |
Getting Prompt Caching to Hit Without Changing the Answer
The rules differ by provider and change often, so check the current documentation for your model. As of November 2026:
- OpenAI turns prompt caching on by default for supported models. Its prompt caching guide requires the entire rendered prefix to match, sets a 1,024-token minimum for GPT-5.6 and later, and says cached input is discounted up to 95%. On GPT-5.6 and later, a cache write with the default 30-minute lifetime costs 1.25 times the uncached input rate; earlier models have no write charge.
- Anthropic uses
cache_controlmarkers: one top-level marker for automatic caching, or up to four explicit breakpoints per request. Its prompt caching documentation prices 5-minute cache writes at 1.25 times base input, 1-hour writes at 2 times, and reads at 0.1 times base input, with lower read rates on some newer models. The prefix is built in the order tools, system, messages, and the minimum cacheable length runs from 512 to 4,096 tokens depending on the model. - Google enables implicit caching by default for Gemini 2.5 and newer models, with a per-model minimum prompt size listed in its context caching guide.
Put stable material first
Inspect what the model actually receives, not the template in your code. Middleware can prepend a request ID or a timestamp, and one changing token at the start makes everything after it a new prefix. Order the input so instructions, examples, output schema and tool definitions come first, in a deterministic order, and the customer message and retrieved evidence come last. Keep IDs the model does not need out of the prompt entirely.
With Anthropic’s hierarchy, a change to a tool definition invalidates the cached system prompt and messages after it, so treat tool schemas as part of the stable prefix and version them. Do not reorder content in a way that changes which instruction takes priority. The goal is the same prompt at a lower price, not a different prompt.
Measure matched tokens, not requests that hit
Two routes can each report a cache hit on 80% of calls. On one, every hit covers 1,500 tokens of fixed instructions. On the other, it covers a short prefix while a long retrieved document changes on every call. The hit rates are identical; the savings are not. Track the share of billed input tokens served from cache, and check what share of the original bill is output. If most of the money goes into writing long reports, a cheaper input prefix cannot move the total much. Shorter responses or a smaller model for that step will.
Test cold starts, quiet hours and deploys
Cache entries expire after minutes of inactivity on default settings, so a quiet route can pay write rates most of the day. Send a cold request and several repeats, then repeat after a realistic idle gap. Staging results may not carry over if production uses a different model version, region or routing. Log the prompt version, so that a drop in hit rate on release day has an obvious cause.
Do not pad a prompt to cross a provider minimum. Making a 900-token instruction set longer just to qualify for a discount can raise the bill on cold or low-volume routes, especially where writes cost more than ordinary input. Compare the full cold and warm paths against a compact uncached prompt, weighted by how often each occurs. A longer stable prefix is justified only when it improves the answers.
What a Semantic Cache Must Check Before Reusing an Answer
Decide eligibility before searching
Start with intents that have stable answers and low cost if the wording varies. A public explanation of how a feature works is easier to reuse than an answer about a payment, a shipment or an account. Classify the operation first: general information, a live value or a change of state. Live values and actions bypass reuse. If deciding eligibility needs its own model call, count that call in the cost model. The route, a known intent or structured fields can usually decide it for free.
Partition first, then compare
Search only among answers the current request is allowed to use. Tenant, product, language, permission scope, plan and policy version are the usual partitions. Microsoft’s semantic cache lookup policy for Azure API Management shows the pattern: a vary-by expression partitions entries, for example by subscription or user group, and the documentation warns that similarity-based reuse “can surface responses that are incorrect, outdated, or unsafe” for the current request.
The same policy shows why no threshold travels between systems. Its score is a distance from 0.0 to 1.0 where lower values demand closer matches; Microsoft suggests starting around 0.05 and notes that values above 0.2 may lead to mismatches. Other tools use cosine similarity, where higher means closer. Different embedding models and indexes produce different scales, so tune the threshold on your own labeled examples.
Check what vectors miss
“Can I export from the free plan?” and “Can I export from the paid plan?” land next to each other in an index, and the answer differs. “Within 30 days” and “after 30 days” differ. A single negation can reverse the question. Pull decision-critical attributes such as plan, dates, amounts, names and policy exceptions from trusted application context, and compare them before serving. If one is unknown and could change the answer, ask the customer or take the live path. Never serve a stored answer just because nothing better came back.
Store only answers you would want repeated
A call can succeed technically and still return a guess or a citation that does not support its conclusion. Store everything and one bad answer becomes a repeated one. For the first rollout, store approved answers or live answers that pass defined checks, and reject timeouts, low-confidence outputs and anything containing data the next asker should not see. Keep the source, policy version and expiry with each entry, and treat embeddings as sensitive derived data that needs the same deletion path as the answer.
Putting Both Caches in One Request Path
The two layers stack without double-counting. A validated semantic hit returns the stored answer. A miss or a bypass goes to the model, where the stable prefix can still hit the provider’s prompt cache. A gateway in front of the model is a natural place to enforce this, because it sees the route, the identity context, the cache result and the provider call in one place.
A Practical Request Flow for Both Caches
1. Classify the request: Decide whether it is shareable information, a live lookup, or an action. Apply identity and access rules before reusing an answer.
2. Find a candidate: Try a strict key if one exists. Use semantic matching only on the eligible route and within the authorized partition.
3. Validate the match: Check constraints that could change the result, including plan, source revision, language, and freshness. A candidate that fails any required check is a miss.
4. Serve or generate: Return a valid stored answer with the correct application response format. On misses and bypasses, use the live path and measure any eligible prompt-cache reuse.
5. Store carefully: Write only validated answers into the correct scope and keep the source version, expiry, and invalidation identifiers with the response.
6. Record the outcome: Track safe served hits, uncached and cached input tokens, output, elapsed time, and any recontact or correction.
Placement decides what a hit saves. If the application must read private data to know whether an answer is safe, the cache cannot skip that read; it can only skip writing the final wording. Where a cheap route check is enough, the cache can sit before document search and save both search and generation. Never count savings for work that still runs on a hit.
Plan the failure case. When the cache is down, eligible questions fall back to generation, which keeps the service up but can spike spend and rate-limit use. Microsoft recommends a rate-limit policy right after the cache lookup for this reason. Give the lookup a deadline so a slow index does not delay every request, and keep authorization separate: a cache outage must never decide who can see what.
A Worked Example: How a Bill Falls 70%
Take a fictional public help assistant with 1 million requests a month. Each request makes one generation call with 2,000 input tokens and 500 output tokens. The rates are illustrative, not a vendor quote: $2 per million input tokens, $0.20 per million cached input tokens and $8 per million output tokens, with no cache-write premium and no other fees on this route.
The uncached baseline is $8,000: 2 billion input tokens cost $4,000 and 500 million output tokens cost $4,000. Half the bill is output, which prompt caching cannot touch.
Step 1: prompt caching on the calls that still run
Assume 1,500 of the 2,000 input tokens are a reusable prefix and 80% of calls hit it over the month. That averages 1,200 cached tokens and 800 ordinary tokens per call. Each call now costs $0.00584: $0.00160 ordinary input, $0.00024 cached input and $0.00400 output. Across one million calls that is $5,840, a 27% saving, and it shows why prompt caching alone cannot reach 70% here.
Step 2: safe semantic reuse before generation
Now assume 60% of all requests get a correct, eligible and current answer from the semantic cache. Only 400,000 requests call the model, costing $2,336. Add an assumed $64 a month for embeddings, lookups, storage and related infrastructure, and the total is $2,400. That is $5,600, or 70%, below the baseline. The $64 is an assumption, not a budget: a dedicated index, an extra screening call or heavier monitoring would raise it, and one-time engineering is not included.
| Scenario | Model calls | Monthly measured cost | Savings vs. baseline |
|---|---|---|---|
| No caching | 1,000,000 | $8,000 | 0% |
| Prompt caching only | 1,000,000 | $5,840 | 27% |
| Both layers, 20% safe semantic reuse | 800,000 | $4,736 | 40.8% |
| Both layers, 40% safe semantic reuse | 600,000 | $3,568 | 55.4% |
| Both layers, 60% safe semantic reuse | 400,000 | $2,400 | 70% |
Step 3: test the target against your own numbers
The table holds the cost of each remaining call constant, which flatters the result. Removing the easy repeat questions leaves harder, more varied traffic behind, so recalculate rather than reuse the average. Separate the candidate rate from the safe served rate too: if 75% of requests find a nearby match but only half pass the checks, real reuse is 37.5%.
To find the hit rate a target needs, subtract the cache overhead from the target monthly bill and divide by the number of requests times the cost of one live call after prompt caching. That gives the largest share of requests that can still miss; one minus it is the safe hit rate you need. Rerun it if answers grow from 500 to 1,000 output tokens, if your model’s cached-input discount is smaller, or if answers can only be shared within each tenant, which splits the audience and lowers hit rates. Budget for lower reuse rather than weakening isolation.
Requests That Should Never Share an Answer
Write the exclusion list before the inclusion list. Current balances, shipment or appointment status, permissions, system availability, recommendations built on private fields, and any request to send, book, change or delete something need a live check or an action that a similar sentence cannot replace. A stored line saying a refund was issued must never stand in for the transaction that issues it. You can reuse standard wording after the live workflow confirms what happened, but keep the action, its record and the text separate in the code and in the metrics.
Treat public answers shared across tenants as a separate, deliberately curated store. Signing in does not entitle anyone to another account’s stored answers. Decide what happens when a tenant changes plan or a user loses access while an answer is still cached. A correct answer served to the wrong audience is still a failure.
Expiry times are one safeguard, not the only one. If a policy changes at noon, an answer cached at 11:59 is wrong a minute later even if it expires tomorrow. Tag entries with the source revision and invalidate them when it changes; where no version exists, use a short expiry or bypass the intent. Keep a kill switch per cache partition so one bad policy does not force the whole service offline.
Measuring Savings Without Rewarding Bad Answers

Build a benchmark that is hard to pass by accident
Collect real requests with privacy controls in place. Include exact repeats, clean paraphrases and near matches that must not reuse an answer: “before” versus “after” a deadline, product names that look alike, negations, two plans with different limits, other languages, and the same wording from different tenants or permission levels. For each, record whether a hit is allowed and which fields would invalidate it. Tune the threshold on one set and check it on a held-out set, and include a policy change between storing and asking.
Run shadow traffic before serving
In a shadow test the lookup runs, but the customer still gets the live answer. Log each candidate and have a reviewer judge it against approved policy, not against the live answer, which can be wrong too. You pay for both lookup and generation during the test, so budget it separately from the forecast. Then serve cached answers on one stable route for a narrow set of intents, keep a holdout, and disable reuse immediately on any scope or access violation.
Track cost and quality together
Explain the invoice movement with safe served hit rate, cached and ordinary input tokens, output tokens, fallback rate and cache infrastructure cost. Next to them, track latency, resolution, recontacts, corrections and escalations. A customer who gets a fast, wrong answer and asks again costs more in tokens and support time. Report spend per 1,000 eligible requests and cost per successful resolution; the framework for measuring AI return on investment helps turn that into a business decision.
Mistakes That Distort the Business Case
Adding the two headline savings percentages
If prompt caching lowers the cost of a live model call by 27% and semantic caching avoids 60% of calls, the combined number isn’t 87%. The prompt discount acts only on calls still sent to the model. In the worked example, 40% of the original calls remain at 73% of the original per-call cost. That is 29.2% of baseline before added cache costs, not 13%.
Using a single threshold across every intent
A forgiving similarity threshold might work for public feature definitions and fail for billing or contract language. Start conservatively and vary eligibility by route. For many intents, the right choice is to never serve a semantic hit. A cautious miss still gets a live answer. A false hit may make a user act on incorrect information without realizing it was retrieved from another context.
Ignoring how cache reads and writes show up on the invoice
Some deployments have separate prices or operational constraints for cache reads and writes. The first request to seed a prefix can have a different cost from subsequent reads. Model migrations, unique user prompts, or sparse routes can leave a workload mostly paying write or cold rates. Use observed billing categories, not marketing language about maximum input discounts.
Treating lookup failures as generation failures
A cache connection problem is not necessarily a production model outage. Route healthy requests to the standard path after access checks and record the loss of savings separately. Use timeouts and monitor whether traffic surges overwhelm the live path. If every user sees an error because an optional optimization failed, the cache has become a reliability risk rather than a cost control.
Building vector search for a problem that needs an exact answer
Many templated inquiries can be routed to an approved answer with a deterministic intent and an exact key. That can outperform embeddings on both cost and predictability. Start with the least complex retrieval method that handles the actual ambiguity. Add semantic matching when the data shows meaningful differences in wording that exact routing cannot handle well.
Which Cache to Start With
Let the bill and the traffic choose. If long instructions repeat on nearly every call, start with prompt caching. If large volumes of public questions differ mainly in wording, compare an exact response cache with a semantic one. If the workload is personal, action-driven or mostly original writing, look at output length and model choice before answer reuse.
Founder Decision Signals
Repeated Long Instructions
Start with prompt caching when the same eligible prefix dominates ordinary input charges. Inspect matched tokens on live routes and check for frequent cold starts.
Many Safe Paraphrases
Pilot response reuse for stable, approved questions. Compare a strict lookup with semantic matching before paying for extra retrieval.
Frequently Changing Facts
Prioritize a fresh data source and reliable invalidation. Keep live values out of a shared answer cache unless you can verify the facts first.
High Output Spend
Look for avoidable generation, evaluate shorter answers, and model the savings on outputs separately from input discounts.
Roll out in that order. Pick one route with steady traffic and a known billing path, and baseline it. Clean up the prompt prefix and confirm the cached tokens in usage data. Pilot answer reuse on a few approved intents with shadow traffic and fallbacks. Recalculate net savings from the actual invoice before extending to the next route, and review hit quality, stale-answer risk and rate changes monthly after that.
Where Miracuves Fits
Miracuves builds LLM applications as custom work. Its LLM development service treats running cost as part of the build: the page names prompt caching, re-ranking fewer passages and routing easy questions to a smaller model as the ways the team keeps the monthly bill predictable, with cost caps set per user or per tenant from launch. Semantic answer reuse, its eligibility rules and the evaluation set behind it are scoped per project, because they depend on your intents and your data.
Whoever builds it, ask for the same proof: one batch of requests run through the uncached path, the prompt-cached path and the combined path, including cases that must miss, such as a changed plan, a different tenant and a question about the customer’s own order. Then ask to see the usage logs, a policy invalidation, a cache-outage fallback and a reconciliation against the invoice. Bring a route-level usage export to that first conversation. The target is a smaller bill you can explain from measured usage and verified answers, whether or not it reaches 70%.
Frequently Asked Questions
What is the difference between prompt caching and semantic caching?
Prompt caching is done by the model provider: when the start of your input matches a recent request exactly, that part is billed at a lower rate, but the model still writes a new answer. Semantic caching is done by your application: it returns a stored, approved answer to an equivalent request and skips the model call, so it saves output tokens too.
Can caching really cut an LLM bill by 70%?
Only in some workloads. In this article’s worked example, prompt caching saves 27% and a 60% safe semantic reuse rate brings an $8,000 monthly bill to $2,400 after assumed cache costs. Workloads with long unique outputs, personal data or actions will save much less. Calculate the hit rate your target needs and compare it with what shadow testing shows.
Does prompt caching reduce output token costs?
No. Prompt caching lowers the cost of repeated input and can shorten the time before the response starts, but the model still generates the answer and output is billed at the normal rate. Only skipping the call, through an exact or semantic response cache, removes output charges, which is why output-heavy routes gain little from prompt caching alone.
Do cache writes cost extra?
On some providers and models, yes. As of November 2026, Anthropic charges 1.25 times the base input price for 5-minute cache writes and 2 times for 1-hour writes, and OpenAI charges 1.25 times for default cache writes on GPT-5.6 and later. Routes with sparse traffic can end up paying mostly write rates, so check the usage fields.
How do you choose a similarity threshold for a semantic cache?
Tune it on labeled examples from the real route, including near matches that must be rejected, and confirm it on a separate held-out set. Scales differ between tools: some use a distance where lower is stricter, others cosine similarity where higher is stricter. Hard checks on plan, dates, amounts and permissions still apply whatever the score says.
When is an exact cache better than a semantic cache?
When a canonical query, button action or structured key already identifies the right answer. An exact key lookup needs no embeddings, is cheaper and is easier to validate. Semantic caching is worth its extra cost and risk only when the same eligible question arrives in many different wordings that a strict key cannot catch.
Miracuves is an independent software development company. We are not affiliated with, connected to, sponsored by, or endorsed by any company or product named in this article.
Terms such as “X Clone” are used descriptively. It is how the software industry refers to building a platform with functionality comparable to a known service, and how clients search for it.
The entire design and codebase of our products is built by our own team. Our products contain no code, design, graphics, or content originating from any third-party website or applications.
All third-party names and marks referenced in this article are the property of their respective owners, referenced solely to identify the services discussed.


