Migrate from Open Source to Platform - Mem0

Overview

Scope Effort Downtime
Infrastructure & Code Low (~30 mins) None (Parallel run possible)

Using Mem0 Open Source with hosted Qdrant? You can migrate your existing memories to Mem0 Platform with a one-line script below.

Why migrate to Platform?

Plan

  1. Sign up: Create an account on Mem0 Platform.
  2. Get API Key: Navigate to Settings > API Keys and generate a new key.
  3. Review Usage: Identify where you instantiate Memory and where you call search or get_all.

Migrate with Agent Skill

Paste this prompt into your coding agent. It uses a migration skill to produce a plan; once you review and approve it, the agent implements the changes.

Migrate my project from Mem0 OSS to the Mem0 Platform SDK using the
mem0-oss-to-platform skill in the mem0ai/mem0 repo, at
skills/mem0-oss-to-platform/

Get the skill whichever way is easiest:
- install it: npx skills add https://github.com/mem0ai/mem0 --skill mem0-oss-to-platform
- if the mem0 repo is cloned locally, read it from skills/mem0-oss-to-platform/
- otherwise fetch that folder from github.com/mem0ai/mem0 (SKILL.md + references/)

Then read SKILL.md and begin the migration.

Migrate

1. Import Memories Into Platform

If your Mem0 Open Source setup uses hosted Qdrant as the vector store, you can import your existing memories to Mem0 Platform with one command:

curl -fsSL https://raw.githubusercontent.com/mem0ai/mem0/main/scripts/oss-to-platform-migrate.sh | bash

This migration script currently supports hosted Qdrant only. Support for local Qdrant, pgvector, and other vector stores is coming soon.

If you are using a different vector store and want to migrate to Platform, please contact Mem0 support and we’ll send you a custom migration script for your setup.

2. Install or Update SDK

Ensure you have the latest version of the SDK, which supports both OSS and Platform clients.

pip install mem0ai --upgrade

3. Update Initialization

Switch from the local Memory class to the managed MemoryClient.

Open Source (Old)

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)

Platform (New)

from mem0 import MemoryClient
import os

# Set MEM0_API_KEY in environment or pass explicitly
client = MemoryClient(api_key="m0-...")

Run client.get_all(filters={"user_id": "test_connection"}) to verify your API key works. It should return an empty list or valid results.

4. Update Retrieval Calls (Critical)

Critical Change: Platform uses v2 endpoints that require filtering parameters to be nested inside a filters dictionary.

The limit parameter has been removed in favor of top_k across all SDKs. Update any code using limit= to use top_k= instead.

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 Memories

Open Source (Old)

# Basic search with user filter
results = m.search("user's preferences", user_id="alex")

Platform (New)

# Basic search with user filter in filters dict
results = client.search("user's preferences", filters={"user_id": "alex"})

Get All Memories

Open Source (Old)

# Get all memories for a user
memories = m.get_all(user_id="alex", top_k=10)

Platform (New)

# Get all memories for a user
memories = client.get_all(filters={"user_id": "alex"}, top_k=10)

Add Memories

Open Source (Old)

# Add a simple memory
m.add("Loves coffee", user_id="alex")

Platform (New)

# Add a simple memory (no change)
client.add("Loves coffee", user_id="alex")

Delete Memories

Open Source (Old)

# Delete specific memory
m.delete(memory_id="mem_123")

Platform (New)

# Delete specific memory (no change)
client.delete(memory_id="mem_123")

Update Memory

Open Source (Old)

# Update memory content
m.update(memory_id="mem_123", new_memory="Updated content")

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")

Platform-Exclusive Features

The Platform introduces powerful capabilities not available in OSS:

Organizations & Multi-tenancy

Why it matters: Manage multiple teams and projects with hierarchical access control.

# 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="team@acme.com",
    role="admin"
)

Webhooks for Real-time Events

Why it matters: Instantly react to memory changes in your application. Build features like notifications, audit logs, or sync with external systems.

# Create webhook for memory events
webhook = client.webhooks.create(
    project_id="proj_123",
    name="Memory Events",
    url="https://your-app.com/webhooks/mem0",
    events=["memory_add", "memory_delete"]
)

Memory Export

Why it matters: Export your data for compliance, analytics, or migration with custom schemas and filters.

# Export memories with custom schema
export_job = client.memories.export(
    filters={
        "AND": [
            {"user_id": "user_123"},
            {"created_at": {"gte": "2024-01-01"}}
        ]
    },
    output_format="json",
    schema={
        "memory": str,
        "categories": list[str],
        "timestamp": str
    }
)

Enhanced Search

Why it matters: Get better search results with AI-powered reranking and keyword expansion.

# Search with reranking for better results
results = client.search(
    "user preferences",
    filters={"user_id": "alex"},
    rerank=True,  # Platform exclusive
    top_k=5
)

Custom Categories

Why it matters: Use domain-specific categories instead of generic ones for better organization.

# Set custom categories for your project
client.project.update(
    custom_categories=[
        {"customer_preferences": "Likes, dislikes, and product preferences"},
        {"product_feedback": "Feature requests and complaints about the product"},
        {"support_issues": "Problems reported and how they were resolved"}
    ]
)

Events API for Analytics

Why it matters: Track all memory operations for audit trails, usage analytics, and debugging.

# Get audit trail of all memory operations
events = client.events.list(
    filters={
        "AND": [
            {"user_id": "alex"},
            {"event_type": "memory_add"},
            {"timestamp": {"gte": "2024-01-01"}}
        ]
    },
    top_k=100
)

Summary of Changes

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

Rollback plan

If you encounter issues, you can revert immediately by switching your import back.

  1. Revert Code: Change MemoryClient back to Memory.
  2. Restore Config: Uncomment your local vector store and LLM configuration.
  3. Verify: Ensure your local vector database is still running and accessible.

Next Steps