messkan/prompt-cache
Cut LLM costs by up to 80% and unlock sub-millisecond responses with intelligent semantic caching.A drop-in, provider-agnostic LLM proxy written in Go with sub-millisecond response
What it solves
PromptCache reduces the cost and latency of LLM applications by avoiding redundant upstream API calls. It addresses the problem of repeated or near-repeated requests in workloads like RAG applications, AI agents, and support bots where similar questions often receive the same answer.
How it works
It acts as a self-hosted proxy between an application and an LLM provider. It uses a two-threshold semantic matching strategy to determine if a new prompt is similar enough to a cached response:
- High similarity: Results in a direct cache hit.
- Low similarity: Results in a cache miss.
- Gray zone: Optionally uses a smaller model to verify the intent of the prompt before serving a cached response.
It is OpenAI-compatible, meaning it can be used with existing SDKs by simply changing the base URL. It persists data using BadgerDB and supports streaming responses via SSE.
Who it’s for
Developers building production GenAI workloads who want to lower provider costs, reduce response times, and increase their rate-limit headroom.
Highlights
- OpenAI-compatible API: Seamlessly integrates with existing OpenAI-compatible clients.
- Semantic Matching: Uses embeddings to find similar prompts rather than exact string matches.
- Multi-provider support: Works with OpenAI, Mistral AI, and Anthropic/Claude (via Voyage AI).
- Runtime Configuration: Allows updating similarity thresholds and providers without restarting the service.
- Cache Warming: Supports pre-populating the cache with known prompt-response pairs.
- Observability: Includes Prometheus metrics and structured logging.
Related
- Dispatch
- Project
- Project
- Project
- Project