Privacy-first memory API for LLMs
Project description
rec0 Python SDK
Official Python client library for rec0 - Persistent memory infrastructure for AI applications.
Quick Start
from rec0 import Memory
# Initialize with your API key
mem = Memory(
api_key='r0_live_sk_...',
user_id='user_123'
)
# Store a memory
mem.store("User prefers dark mode and Italian food")
# Recall relevant memories
context = mem.recall(query="user preferences")
print(context)
# Returns: "User prefers dark mode and Italian food"
Install
pip install memorylayer-py
Note: The package name is memorylayer-py but you import it as rec0:
from rec0 import Memory # Import name is 'rec0', not 'memorylayer'
Get Your API Key
- Sign up at rec0.vercel.app
- Get your API key from the dashboard
- Start building!
Documentation
Features
- Auto-Capture: Automatically extracts entities, facts, and preferences
- Smart Retrieval: Hybrid BM25 + cosine similarity search
- Memory Decay: Intelligent aging and conflict resolution
- Privacy-first: Per-user encryption, data isolation, and GDPR-compliant deletion. Your users' data is encrypted and never shared with third parties.
- LLM-Agnostic: Works with any LLM (OpenAI, Anthropic, Google, local models)
rec0 vs Mem0
| rec0 | Mem0 |
|---|---|
| Privacy: Per-user encryption & isolation | Standard cloud storage |
Enterprise Deployment
The Python SDK is fully open source (MIT license). The backend API is closed source but available for enterprise on-premise deployment.
For self-hosted deployments, contact: enterprise@rec0.vercel.app
Examples
Basic Usage
from rec0 import Memory
mem = Memory(api_key='r0_...', user_id='user_123')
# Store
mem.store("User is a Python developer")
# Recall
context = mem.recall(query="programming")
AI Chatbot with Memory
from rec0 import Memory
from openai import OpenAI
mem = Memory(api_key='r0_...', user_id='user_456')
ai = OpenAI()
# Get relevant context
context = mem.recall(query=user_message)
# Send to LLM with context
response = ai.chat.completions.create(
model="gpt-4",
messages=[
{"role": "system", "content": f"Context: {context}"},
{"role": "user", "content": user_message}
]
)
# Store the conversation
mem.store(f"User: {user_message}\nAssistant: {response}")
See examples/ for more.
API Reference
Memory(api_key, user_id, app_id=None, base_url=None)
Initialize the memory client.
Parameters:
api_key(str): Your rec0 API keyuser_id(str): Unique identifier for the userapp_id(str, optional): Application identifierbase_url(str, optional): Custom API endpoint
store(content, metadata=None)
Store a memory.
Parameters:
content(str): The content to remembermetadata(dict, optional): Additional metadata
Returns: dict with memory_id
recall(query, limit=10)
Retrieve relevant memories.
Parameters:
query(str): Search querylimit(int): Maximum number of results
Returns: list of memory objects
delete(memory_id=None, user_id=None)
Delete memories.
Parameters:
memory_id(str, optional): Specific memory to deleteuser_id(str, optional): Delete all memories for user
Contributing
Contributions are welcome! See CONTRIBUTING.md for guidelines.
License
MIT License - see LICENSE file for details.
Links
Support
- GitHub Issues: Report bugs
- Email: support@rec0.vercel.app
Made with ❤️ by rec0
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 memorylayer_py-0.1.1.tar.gz.
File metadata
- Download URL: memorylayer_py-0.1.1.tar.gz
- Upload date:
- Size: 7.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d7b59254d7ef07a151bcf6b6d3a4b68563fc53a7aed6a1cc82838e2e3e618ef1
|
|
| MD5 |
ad2a721fe908e8212c241f52bed78576
|
|
| BLAKE2b-256 |
42ca516963bd30264ca41384a40d3ebc4dd146f301827a9e6fd708244c916c57
|
File details
Details for the file memorylayer_py-0.1.1-py3-none-any.whl.
File metadata
- Download URL: memorylayer_py-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.11.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3e108b7b66f4366a722e8f1194994a067411ca8fd57525c6b2f506a1a8f02fd6
|
|
| MD5 |
c2a768593f76f414e40c664fa5fc21b4
|
|
| BLAKE2b-256 |
d45c04537f96a2f440e49600cafa7b2d27f7c4142ea6c907b8728226d245fe4b
|