See what semantic caching is worth before you build it
If your app answers similar questions over and over — support queries, FAQs, repeated lookups — many LLM calls are redundant. A semantic cache returns a stored answer when a new query is close enough in meaning to a previous one, skipping the model call entirely. This estimator models the saving from your own volume, hit rate and token sizes so you can decide whether caching is worth the engineering effort.
How it works
Every uncached request costs (input_tokens × input_price) + (output_tokens × output_price). A cache hit avoids that call completely, so it saves the full
per-call cost. The estimator multiplies your monthly request volume by your
cache hit rate to find how many calls are served from cache, then multiplies
that by the per-call cost to get the monthly saving. The result shows your bill
with and without the cache side by side, plus the percentage saved.
What is a realistic hit rate?
Hit rate varies enormously by application type:
- Customer support bots — users ask variations of the same 50–100 questions. Hit rates of 40–60% are common once the cache warms up.
- FAQ assistants — even higher repetition; a well-warmed cache can exceed 60–70%.
- Code assistants or general chat — far lower; each conversation is unique. Expect single-digit hit rates.
- Structured lookup tools (product search, entity extraction from known sets) — moderate repetition, 20–40%.
The warm-up period matters: a fresh cache has zero hits. Volume and hit rate both ramp as the cache fills. For this estimator, enter your expected steady-state hit rate, not day-one performance.
How semantic caches work under the hood
A semantic cache stores the embedding vector of each past query alongside the response. When a new query arrives, the cache embeds it and performs a nearest-neighbour search. If the closest past query is within a configurable similarity threshold (commonly a cosine distance under 0.1–0.2), the stored response is returned. If not, the query goes to the LLM and the result is stored for future use.
The key tuning variable is the similarity threshold. Setting it too loose means semantically distant queries get served the same cached answer, producing wrong results. Setting it too tight means the hit rate collapses and the cache provides little value. Good practice is to run the threshold calibration on a sample of real traffic: log the matched query pairs at a given threshold and have a human judge whether the cached answer was appropriate.
Tools and libraries
Common options include GPTCache (open-source, supports multiple embedding and storage backends), Momento Cache (managed, vector search built in), and roll-your-own approaches using pgvector or a dedicated vector store like Pinecone or Weaviate. The cost math in this estimator is independent of which backend you choose.
Tips for real-world caching
- Match savings to repetition. Caching pays off most when traffic is repetitive. Measure your actual similar-query rate before committing.
- Tune the similarity threshold. Too loose and you return wrong answers; too tight and your hit rate collapses. Validate against real queries.
- Set a TTL. Expire cached entries so answers stay fresh when your data or prompts change.
- Account for the cache’s own cost. Embeddings and storage add a small overhead — usually a fraction of the LLM call — so net savings are slightly below the headline figure here.