Universal caching system for AI responses with support for memory, file (JSON), and Redis backends.
Project description
AI CacheKit
Lightweight caching library for AI/LLM API responses.
Reduce costs and improve performance by storing API responses locally with hash-based keys and optional TTL.
Features
- 🔹 Simple API:
get,set - 🔹 Local JSON storage (no external DB required)
- 🔹 Optional TTL (time-to-live) for cache expiration
- 🔹 Perfect for OpenAI, Anthropic, Ollama, etc.
Installation
From GitHub (development version):
pip install git+https://github.com/EDLadder/ai-cachekit.git
From PyPI (after release):
pip install ai-cachekit
Usage
from ai_cachekit import AIResponseCache
cache = AIResponseCache(backend="memory")
cache.set("question", "answer")
print(cache.get("question"))
File-Based Cache (JSON)
cache = AIResponseCache(backend="file", filepath="my_cache.json")
cache.set("key", "value")
print(cache.get("key"))
Redis Cache
cache = AIResponseCache(backend="redis", host="localhost", port=6379)
cache.set("key", "value")
print(cache.get("key"))
Why?
- Avoid repeated API calls (save cost & time)
- Minimal dependencies and setup
- Flexible for any AI API (OpenAI, LLaMA, etc.)
Development
Clone repo and install dev dependencies:
git clone https://github.com/EDLadder/ai-cachekit.git
cd ai-cachekit
pip install -r requirements.txt
pytest
Plans
- Support for Redis and SQLite backends.
- CLI tool for managing cache.
- Built-in stats: hit rate, saved cost estimation.
- Encryption for cached data.
License
MIT License – free to use and modify.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file ai_cachekit-1.0.0.tar.gz.
File metadata
- Download URL: ai_cachekit-1.0.0.tar.gz
- Upload date:
- Size: 4.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e07d8ca679fa9dbceeaa3d9477d3afafc36e36adc6f041121c03a6fadfe15dc9
|
|
| MD5 |
46682eb7a5eed4c9e8e1c6beda6aa178
|
|
| BLAKE2b-256 |
d9461f8710b1f44c1ece804cb5d7824174f1a6dd1629b3c772ed013bc0c3a0ee
|
File details
Details for the file ai_cachekit-1.0.0-py3-none-any.whl.
File metadata
- Download URL: ai_cachekit-1.0.0-py3-none-any.whl
- Upload date:
- Size: 5.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.5
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7f27dcb6d1d9344bbb22ef57d5a48d77a8e40a3dd7e96a361be3030167c22b0c
|
|
| MD5 |
793e94706f9847f181dcb7edf2e138a7
|
|
| BLAKE2b-256 |
38c89e792474379a390e51c593af8468dd04015535b9398c8b6d0911dfc0c3e0
|