AgentCache Python Client
Official Python client for AgentCache.ai - The Global Edge Cache for LLMs.
Installation
pip install agentcache
Usage
Standard Completion
import agentcache
# Drop-in replacement for OpenAI call logic
response = agentcache.completion(
model="gpt-4",
messages=[{"role": "user", "content": "Hello world"}],
provider="openai" # optional, defaults to openai
)
if response and response.get('hit'):
print("Cache HIT:", response['response'])
else:
print("Cache MISS - Call your LLM here")
Streaming
AgentCache supports streaming responses, making it compatible with chat UIs that expect Server-Sent Events (SSE).
stream = agentcache.completion(
model="gpt-4",
messages=[{"role": "user", "content": "Write a poem"}],
stream=True
)
if stream:
print("Cache HIT (Streaming):")
for chunk in stream:
content = chunk['choices'][0]['delta'].get('content', '')
print(content, end="", flush=True)
Reasoning Cache (NEW in v0.3.0)
Cache reasoning traces for o1, Kimi, and DeepSeek models:
response = agentcache.completion(
model="o1-preview",
messages=[{"role": "user", "content": "Analyze this contract..."}],
strategy="reasoning_cache"
)
if response and response.get('cached'):
print("Reasoning trace retrieved from cache")
Multimodal Cache (NEW in v0.3.0)
Cache 3D meshes, images, and audio for generative models:
response = agentcache.completion(
model="sam-3d-body",
messages=[{
"role": "user",
"content": "Generate 3D model",
"file_path": "input.jpg"
}],
strategy="multimodal"
)
if response and response.get('cached'):
asset_data = response['asset']
print(f"Retrieved cached 3D asset: {len(asset_data['vertices'])} vertices")
Environment Variables
Set AGENTCACHE_API_KEY in your environment, or pass api_key to the constructor.
from agentcache import AgentCache
client = AgentCache(api_key="ac_live_...")
Metadata
Release files for agentcache 0.3.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| agentcache-0.3.0.tar.gz | 9.2 kB | Without provenance | Details for agentcache-0.3.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| agentcache-0.3.0-py3-none-any.whl | Python 3 | none | any | Details for agentcache-0.3.0-py3-none-any.whl |
Total release size: 18.3 kB
Release files / agentcache-0.3.0.tar.gz
| Download URL | agentcache-0.3.0.tar.gz |
|---|---|
| Size | 9.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
62484c2100a9dcfb6bfbb62cc946bc289bb19d69ab1dbe6426009c0d1b7b20ab
|
|
BLAKE2b-256 checksum How to use checksums |
422c3cf44e77aba1c958c674bff0232d26f6808302b4e28d7753a7ea8a2a5e2c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Release files / agentcache-0.3.0-py3-none-any.whl
| Download URL | agentcache-0.3.0-py3-none-any.whl |
|---|---|
| Size | 9.1 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
3549c67d79888b86d394e717abe1984f9f658e169bdf9b97e3f0d9c5334493e7
|
|
BLAKE2b-256 checksum How to use checksums |
a1ab7a6be8fea77490b6b42b2c77110f470403815c127eac048f51de35c7f3c5
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/6.2.0 CPython/3.13.7
|
Security for agentcache 0.3.0
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.