docs/migration/oss-to-platform.mdx
Move your Mem0 implementation to managed infrastructure with enterprise features.
| Scope | Effort | Downtime |
|---|---|---|
| Infrastructure & Code | Low (~30 mins) | None (Parallel run possible) |
Memory and where you call search or get_all.Ensure you have the latest version of the SDK, which supports both OSS and Platform clients.
pip install mem0ai --upgrade
Switch from the local Memory class to the managed MemoryClient.
from mem0 import Memory
config = {
"vector_store": {
"provider": "qdrant",
"config": {"host": "localhost", "port": 6333}
},
"llm": {
"provider": "openai",
"config": {"model": "gpt-4"}
}
}
m = Memory.from_config(config)
from mem0 import MemoryClient
import os
# Set MEM0_API_KEY in environment or pass explicitly
client = MemoryClient(api_key="m0-...")
| Method | Open Source | Platform |
|---|---|---|
search() | m.search(query, user_id="alex") | client.search(query, filters={"user_id": "alex"}) |
get_all() | m.get_all(user_id="alex") | client.get_all(filters={"user_id": "alex"}) |
add() | m.add(memory, user_id="alex") | client.add(memory, user_id="alex") |
delete() | m.delete(memory_id) | client.delete(memory_id) |
delete_all() | m.delete_all(user_id="alex") | client.delete_all(user_id="alex") |
Note: add() and delete() methods remain unchanged. The update() method is not available in Platform - use delete + add pattern instead.
# Search with multiple filters
results = m.search("meeting notes", user_id="alex", agent_id="assistant")
```
```python Platform (New)
# Basic search with user filter in filters dict
results = client.search("user's preferences", filters={"user_id": "alex"})
# Search with multiple filters
results = client.search("meeting notes", filters={
"AND": [
{"user_id": "alex"},
{"agent_id": "assistant"}
]
})
```
</CodeGroup>
# Get memories with pagination
memories = m.get_all(user_id="alex", top_k=5, offset=10)
```
```python Platform (New)
# Get all memories for a user
memories = client.get_all(filters={"user_id": "alex"}, top_k=10)
# Get memories with pagination
memories = client.get_all(filters={"user_id": "alex"}, top_k=5, offset=10)
```
</CodeGroup>
# Add memory with metadata
m.add("Completed marathon", user_id="alex", metadata={"category": "achievement"})
```
```python Platform (New)
# Add a simple memory (no change)
client.add("Loves coffee", user_id="alex")
# Add memory with metadata (no change)
client.add("Completed marathon", user_id="alex", metadata={"category": "achievement"})
```
</CodeGroup>
# Delete all memories for user
m.delete_all(user_id="alex")
```
```python Platform (New)
# Delete specific memory (no change)
client.delete(memory_id="mem_123")
# Delete all memories for user (no change)
client.delete_all(user_id="alex")
```
</CodeGroup>
```python Platform (New)
# Update memory (not available in Platform)
# Use delete + add pattern instead
client.delete(memory_id="mem_123")
client.add("Updated content", user_id="alex")
```
</CodeGroup>
The Platform introduces powerful capabilities not available in OSS:
<AccordionGroup> <Accordion title="Organizations & Multi-tenancy"> <Info> **Why it matters**: Manage multiple teams and projects with hierarchical access control. </Info> ```python # Create an organization org = client.organizations.create(name="Acme Corp")# Create projects within the organization
project = client.projects.create(
name="Customer Support Bot",
org_id=org.id
)
# Add team members
client.organizations.add_member(
org_id=org.id,
email="[email protected]",
role="admin"
)
```
# Webhook payload example:
# {
# "event": "memory_add",
# "memory_id": "mem_456",
# "user_id": "user_789",
# "memory": "User prefers dark mode",
# "timestamp": "2024-01-15T10:30:00Z"
# }
```
# Download when ready
if client.memories.get_export(export_job.id).status == "completed":
data = client.memories.download_export(export_job.id)
```
# Search with keyword expansion
results = client.search(
"coffee order",
filters={"user_id": "alex"},
keywords=["latte", "espresso", "cappuccino"],
expand_keywords=True
)
```
# Memories will use these categories
client.add(
"User wants dark mode in dashboard",
user_id="alex",
categories=["Customer Preferences"]
)
```
# Monitor usage patterns
for event in events:
print(f"{event.timestamp}: {event.event_type} - {event.memory_id}")
```
| Feature | Open Source | Platform | Action Required |
|---|---|---|---|
| Initialization | Memory.from_config(config) | MemoryClient(api_key) | Replace config object with API key |
| Search Method | m.search(query, user_id="x") | client.search(query, filters={"user_id": "x"}) | Move filtering params into filters dict |
| Get All Method | m.get_all(user_id="x") | client.get_all(filters={"user_id": "x"}) | Move filtering params into filters dict |
| Add Method | m.add(memory, user_id="x") | client.add(memory, user_id="x") | No change |
| Delete Method | m.delete(memory_id) | client.delete(memory_id) | No change |
| Delete All | m.delete_all(user_id="x") | client.delete_all(user_id="x") | No change |
| Update Method | m.update(memory_id, new_memory) | Use delete + add pattern | Replace with delete then add |
| Config | Local vector store + LLM config | Managed cloud infrastructure | Remove local config setup |
If you encounter issues, you can revert immediately by switching your import back.
MemoryClient back to Memory.