Home / Rank #4
Semantic caching
Exact-match caches miss paraphrases. Semantic caching embeds incoming queries and serves a stored answer when a new query is similar enough to a previous one — eliminating 30–70% of redundant API calls in workloads where users ask the same things in different words (support, search, FAQ-style traffic).
It is the natural next step after prompt caching: prompt caching discounts repeated prefixes, semantic caching skips the model call entirely.
How to do it
- Embed each query; store (embedding, response) pairs in a vector store.
- Serve cached responses above a tuned similarity threshold; start conservative (~0.95) and loosen with monitoring.
- Scope caches per-user or per-tenant when answers depend on private context.
- Set TTLs matched to how fast the underlying facts change.
Frequently asked questions
When is semantic caching a bad idea?
When answers are personalized, time-sensitive, or high-stakes. A stale or subtly-wrong cached answer costs more than the tokens it saved. Scope and TTL carefully.
Tools for this method
LiteLLM
The default self-hosted gateway: one OpenAI-compatible proxy across 100+ providers with budgets, caching, routing, fallbacks, and …
Portkey
Managed gateway with the strongest built-in semantic caching, plus guardrails, routing, and cost analytics. The low-ops route to t…
Next method: #5 Batch APIs