Semantic caching
Definition
Reusing a stored model response when a new request means the same as an earlier one, judged by embedding similarity rather than exact text.
In more detail
An exact-match cache only helps when requests are identical. A semantic cache embeds each request, looks for a previous one above a similarity threshold, and returns its answer without calling the model, so 'how do I reset my password' and 'password reset steps' can share a response.
The risk is serving an answer to a question that only looks similar: 'cancel my order' and 'cancel my subscription' may sit close together. Tune the threshold on real traffic, scope the cache per user or tenant when answers depend on who is asking, and expire entries when the underlying data changes. It is different from prompt caching, which reuses computation for a shared prefix but still generates a fresh answer.
Related terms
AI gateway
A proxy between apps and model providers that gives one API for many models and adds keys, logging, budgets, caching and fallbacks.
Cosine similarity
A measure of how similar two vectors are based on the angle between them, ranging from -1 (opposite) to 1 (same direction).
Embedding
A vector representation of text or other data that places items with similar meaning close together, so they can be searched by similarity.
Prompt caching
Reusing the processed form of a repeated prompt prefix, such as a long system prompt, across requests to reduce latency and cost.
Batch API
A provider endpoint that takes many requests at once and returns results later, typically within 24 hours, at a lower price than live requests.
Read more about Semantic caching
- LLM cost optimisation
Cutting LLM costs with caching, model routing, batching and budgets.
- Prompt caching
Reusing the processed form of a repeated prompt prefix, such as a long system prompt, across requests to reduce latency and cost.
- Helicone
AI gateway and observability layer that logs requests, cost and latency.