gptcache
GPTCache, a powerful caching library that can be used to speed up and lower the cost of chat applications that rely on the LLM service. GPTCache works as a memcache for AIGC applications, similar to how Redis works for traditional applications.
What it is and what it does
GPTCache is a caching layer for large language model (LLM) API calls that intercepts queries and returns cached responses when an exact or semantically similar question has been asked before. It works by embedding queries into a vector space and comparing them against stored responses, allowing you to skip expensive API calls for repeated or similar questions.
The library integrates with OpenAI's API (and supports a generic get/set adapter for other LLM providers) and can be configured with different embedding models, vector databases (e.g., FAISS), and similarity evaluation strategies. It depends on numpy, cachetools, and requests for its core functionality, though additional optional dependencies are installed on demand for features like semantic embedding and vector storage.
Use it for:
- Cache exact-match queries to OpenAI's ChatCompletion API to avoid redundant API calls and reduce monthly costs.
- Implement semantic similarity matching so that paraphrased or slightly different versions of the same question return cached answers.
- Reduce latency for high-traffic chatbot applications by serving cached responses instead of waiting for LLM API responses.
- Store embeddings and responses in a persistent vector database (e.g., SQLite + FAISS) to maintain cache across application restarts.
- Control cache behavior with temperature parameters to balance between cache hits and fresh LLM responses.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
GPTCache provides semantic caching for LLM API calls, storing and retrieving responses based on exact or semantic similarity matching to reduce API costs and latency.
Yes, with conditions. GPTCache is worth installing if you run high-volume LLM applications and want to reduce API costs and latency through caching. However, be aware that the project is aging (last release August 2024, no commits since July 2025), two security vulnerabilities are known, and the API is explicitly subject to change. Verify the current status of those vulnerabilities and test thoroughly in a staging environment before production use.
Install
gptcache on PyPI
pip
pip install gptcacheuv
uv add gptcachepoetry
poetry add gptcacheInstalling gptcache
Before you install
Low install friction with three common runtime dependencies (numpy, cachetools, requests). Maintenance status is aging—last release was 2024-08-01 and the repository has not been updated since 2025-07-11, though the project remains active with 8138 stars.
License in practice
MIT license (permissive) allows unrestricted use, modification, and distribution in both open-source and commercial projects.
Quickstart
pip install gptcache
from gptcache import cache
from gptcache.adapter import openai
cache.init()
cache.set_openai_key()
response = openai.ChatCompletion.create(
model='gpt-3.5-turbo',
messages=[{'role': 'user', 'content': 'your question'}]
)
Requires Python 3.8.1 or higher and an OpenAI API key set via OPENAI_API_KEY environment variable.
Verify before relying
- Current status of the two known vulnerabilities (GHSA-xfqj-4cr9-9gr5, PYSEC-2026-3468) and whether patches are available.
- Whether the API remains stable given the note that it 'may be subject to change at any time'.
- Support status for models and API shapes beyond OpenAI, given the stated policy to no longer add new model support.
Package facts
| License | https://opensource.org/license/mit/ (permissive) |
| Python support | supports the current Python release (>=3.8.1) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | 3 — numpy, cachetools, requests |
| Maintenance | aging — 743 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 450,827/month — #6,589 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | 2 — GHSA-xfqj-4cr9-9gr5, PYSEC-2026-3468 |
Evidence: gptcache-0.1.44-py3-none-any.whl
Tags
More Artificial Intelligence packages
LiteLLM provides a unified Python interface to…
permissive · top 100 on PyPI
huggingface-hubClient library and CLI tool for downloading,…
permissive · top 100 on PyPI
langchainLangChain provides a framework for building…
permissive · top 1,000 on PyPI
hf-xethf-xet provides chunk-based deduplication and…
permissive · top 1,000 on PyPI
tokenizersTokenizers converts raw text into token…
permissive · top 1,000 on PyPI
transformersTransformers provides a unified framework for…
permissive · top 1,000 on PyPI
mem0aiMem0 adds a persistent, searchable memory layer…
permissive · top 5,000 on PyPI
memsearchMemsearch builds a searchable semantic memory…
permissive · top 15,000 on PyPI
lmcacheLMCache is a KV cache management layer that…
permissive · top 15,000 on PyPI
tokencostCounts tokens and estimates USD costs for LLM…
permissive · top 15,000 on PyPI
llama-index-legacyLlamaIndex Legacy is a data framework for…
permissive · top 5,000 on PyPI
mooncake-transfer-engineMooncake Transfer Engine provides…
permissive · top 15,000 on PyPI
cacheyCachey provides intelligent caching for…
permissive · top 15,000 on PyPI
langchain-ociIntegrates LangChain with Oracle Cloud…
unclear · top 15,000 on PyPI
openai-chatkitA backend SDK for building chat applications…
unclear · top 15,000 on PyPI