Description
GPTCache is a Python library for building a semantic cache for large language model queries. Instead of calling the model every time, it stores earlier responses and returns them when a new query is similar enough, which can cut API costs and response times for applications with repeated or similar questions. The project is integrated with LangChain and llama_index, and it supports exact matching as well as similar matching with caching. Installation is a single pip command, and the library installs only its basic dependencies at first, adding others automatically when a feature needs them. The project also released a GPTCache server Docker image, so applications written in any language can use the cache over HTTP. The README notes that the project is under heavy development and its API may change, and that the authors no longer add support for new model APIs. They recommend using the get and set API directly, and they provide demo code for it in the examples folder. Python 3.8.1 or later is required, and examples can be run from the repository or on Colab.…
Highlights
- Semantic cache for LLM queries
- Exact and similar matching
- LangChain and llama_index integration
- Server Docker image for any language
- Get and set API
Ratings & Reviews
No ratings yet
Be the first to rate GPTCache.
People also visit

redis-semantic-cache
Redis LangCache guidance for semantic caching of LLM responses on Redis Cloud
GPTCache FAQ
What is GPTCache?
A Python library that caches large language model responses and returns them for similar queries, so the model is not called each time.
How do I install it?
Run pip install gptcache. It needs Python 3.8.1 or later.
Does it work with LangChain?
Yes. The README says it has been fully integrated with LangChain, and it also supports llama_index.
Can other languages use it?
Yes. The README says the GPTCache server Docker image lets any language use the cache.
Does it support new model APIs?
The README says the authors no longer add support for new APIs or models, and recommend the get and set API instead.
Is it stable?
The README says the project is under heavy development and its API may change at any time.
What are the best GPTCache alternatives?
Popular alternatives to GPTCache include Claude Code Cache Fix, Memlayer and SMG. See all GPTCache alternatives