Answer the same question once
Store a model's answers and serve them again for prompts that mean the same thing. Built into every KiviDB Cloud database, with hosted embeddings, your own OpenAI key, or your own vectors.
Many of the prompts your application sends mean the same thing in different words. The semantic cache keeps each answer with the prompt that produced it and serves it again when a new prompt is close enough in meaning, so only a miss goes to the model.
Two calls around your model
- Lookup The prompt is turned into an embedding and compared with the stored ones. The closest that reaches your similarity threshold is returned; otherwise you get a miss and the closest score, to tune by.
- Store On a miss, store the prompt and the model's answer. Each entry keeps for the time you choose, from a minute to a year, and expires on its own.
- Namespaces Keep separate caches for separate assistants or models, each with its own threshold and time to live, and its own entries, hits, misses and hit rate.
Our model, yours, or your vectors
- KiviDB hosted Amazon Titan Text Embeddings V2, run by KiviDB: no API key, $0.05 per million tokens from your credit.
- Your own key OpenAI, or any HTTPS endpoint with the same /embeddings request and response, with your key, stored encrypted and never shown again. Your provider bills you.
- Your own vectors Send the prompt's embedding with every lookup and store, and KiviDB calls no one.
In your database, not ours
- Nothing leaves it Entries are stored in the KiviDB database you run the cache on: a vector set, a hash per entry and a few counters, under keys you can see.
- Sharded too All of a namespace's keys share one hash tag, so on a sharded database a namespace sits on one shard and the cluster routes to it.
- No separate charge The cache uses the database's own memory. There is nothing extra to pay KiviDB for it.
From zero to a hit
- Create a namespace In the console's Semantic cache section, linked to one of your databases, or with one PUT: choose the embedding provider, the model's dimensions, the threshold and how long entries keep.
- Look up before the model Call lookup with the prompt. A hit returns the stored answer and its similarity.
- Store on a miss Call the model as you do today and store its answer, so the next prompt that means the same is a hit.
Questions
What threshold should I use?
It depends on the embedding model. With OpenAI's text-embedding-3-small, reworded questions scored 0.75 to 0.82 against the original at 256 dimensions and 0.61 at 1536, and unrelated ones about 0.1, so the default of 0.6 catches rewordings at either size. Look at the closest score your misses report and tune from there.
Can my assistant use it?
Yes. The MCP server has tools to look up and store entries and to read a cache's statistics, alongside the database tools.
Where are API keys kept?
Your embedding provider's key is stored encrypted in KiviDB Cloud and never returned. API calls to the cache use a KiviDB API key, which can be limited to one database.
Cache your model's answers today
Create a database, add a namespace in the console's Semantic cache section, and wrap your model call in a lookup and a store.