← Back to Blog
Guide

From Mem0 to Cortex: A Migration Guide

Step-by-step guide for teams migrating from Mem0 or Zep to Cortex. Same API patterns, better performance, no vendor lock-in.

Why Teams Migrate to Cortex

Cortex was designed with migration in mind. The API patterns are familiar to Mem0 and Zep users, but the performance, flexibility, and costs are dramatically better.

**Performance**: Sub-5ms retrieval latency vs 50-200ms **Cost**: 75% reduction in LLM invocation costs **Flexibility**: Single PostgreSQL database vs multiple vendor systems **Ownership**: Open-source self-hosting vs vendor lock-in

Step 1: Export Existing Data

Both Mem0 and Zep provide export functionality. Data formats differ slightly, but both can be converted to Cortex's import schema.

# Export from Mem0
mem0 export --format=jsonl > mem0_export.jsonl

# Export from Zep zep export --format=jsonl > zep_export.jsonl

# Convert to Cortex schema cortex convert --source=mem0 mem0_export.jsonl > knol_import.jsonl ```

Step 2: Set Up Cortex Infrastructure

Cortex's infrastructure is minimal: one PostgreSQL instance with pgvector.

# Using Cortex's Helm chart
helm repo add cortex https://charts.cortex.doaide.com
helm install cortex cortex/cortex --namespace cortex --create-namespace

# Or Docker Compose for development docker-compose up -d ```

Step 3: Migrate API Calls

The migration is straightforward because Cortex maintains API compatibility:

# Before (Mem0)
from mem0 import Memory
memory = Memory.from_config(config={"llm": {...}})
memory.add("User details", user_id="user_1")

# After (Cortex) - minimal changes from cortex import CortexClient client = CortexClient(api_key="your_key") client.episodic.add("User details", user_id="user_1")

# If using LangChain, just swap the import from cortex.langchain import CortexMemory memory = CortexMemory(client=client) ```

Step 4: Import Historical Data

Cortex provides bulk import tools optimized for large data sets:

cortex import --source=knol_import.jsonl --batch-size=1000

Import happens asynchronously. You can monitor progress:

cortex import status --job-id=job_123

Step 5: Run Dual Writes (Optional)

For zero-downtime migration, run dual writes for a period:

# Write to both systems during migration window
client.episodic.add(text, user_id=user_id)
mem0_client.add(text, user_id=user_id)  # temporary

# Query from Cortex, fallback to Mem0 if needed try: result = knol_client.retrieve(query, user_id=user_id) except Exception: result = mem0_client.search(query, user_id=user_id) ```

Step 6: Update LLM Extraction Pipelines

If you have custom extraction prompts, they should work unchanged in Cortex. But you might want to take advantage of Cortex's structured extraction:

# Cortex provides extraction types for common patterns
result = client.semantic.extract(
    conversation_turn=turn,
    extraction_type="preferences",  # Cortex knows what facts to extract
    user_id=user_id
)

Rollback Plan

If issues arise, you have a complete snapshot of the old system. Cortex's import is non-destructive — your original data still exists. You can:

1. Keep both systems running during a transition period 2. Query Cortex as primary, fall back to Mem0 if needed 3. Compare retrieval results between systems 4. Gradually route 100% of traffic to Cortex

Common Issues and Solutions

**Query results differ slightly**: Cortex's hybrid retrieval returns different results than Mem0's pure vector approach. This is usually better, but you can adjust weights in configuration.

**LLM costs increased during import**: Bulk extraction to populate semantic memory is expensive. But day-to-day operations will be 75% cheaper.

**Authentication changes**: If you're self-hosting, you control authentication entirely. Configure your preferred auth system (OAuth, SAML, API keys) directly.

Timeline

Typical migration timeline:

- **Week 1**: Export and evaluation - **Week 2**: Infrastructure setup and small-scale testing - **Week 3**: Data import and validation - **Week 4**: Dual write and monitoring - **Week 5**: Full cutover

The process is straightforward, and our team can assist at any stage.