Skip to content

Skip to main content

Mem0 home pagelight logodark logo

Search...

Ctrl KAsk AI

Search...

Navigation

Agent Frameworks

Camel AI

Welcome Mem0 Platform Open Source Cookbooks Integrations API Reference Release Notes

Overview
Agent Frameworks
Voice & Real-time
Cloud & Infrastructure
Developer Tools

On this page

Camel AI integration

Connect Camel’s agent framework to Mem0 so every agent can persist and recall conversation context across sessions with minimal setup.

Prerequisites

  • Mem0: MEM0_API_KEY (or self-hosted endpoint), pip install mem0ai
  • Camel AI: pip install camel-ai (requires Python 3.9+)
  • Optional: OpenAI API key if you run LLM-backed agents

Camel provides a Python SDK today. A TypeScript path is not available yet.

Configure credentials

  • Mem0

  • Camel

1

Navigate to header

Export your API key

export MEM0_API_KEY="sk-..."

2

Navigate to header

(Self-host) Point to your Mem0 API

export MEM0_BASE_URL="https://your-mem0-domain"

1

Navigate to header

Install Camel with Mem0 dependency

pip install "camel-ai>=0.2.0" mem0ai

2

Navigate to header

(Optional) Add your model credentials

export OPENAI_API_KEY="sk-openai..."

Mem0Storage reads MEM0_API_KEY automatically. Pass api_key explicitly only when you need to override the environment.

Wire Mem0 into a Camel agent

1

Navigate to header

Create a Mem0-backed memory store

import os
from camel.storages import Mem0Storage

mem0_store = Mem0Storage(
    api_key=os.environ.get("MEM0_API_KEY"),
    agent_id="travel_agent",
    user_id="alice",
    metadata={"source": "camel-demo"},
)

2

Navigate to header

Attach it to Camel memory

from camel.memories import ChatHistoryMemory, ScoreBasedContextCreator
from camel.utils import OpenAITokenCounter
from camel.types import ModelType

memory = ChatHistoryMemory(
    context_creator=ScoreBasedContextCreator(
        token_counter=OpenAITokenCounter(ModelType.GPT_4O_MINI),
        token_limit=1024,
    ),
    storage=mem0_store,
    agent_id="travel_agent",
)

3

Navigate to header

Let your agent read and write Mem0

from camel.agents import ChatAgent
from camel.messages import BaseMessage

agent = ChatAgent(
    system_message=BaseMessage.make_assistant_message(
        role_name="Agent",
        content="You are a helpful travel assistant. Reuse stored memories."
    )
)

agent.memory = memory

response = agent.step(
    BaseMessage.make_user_message(
        role_name="User",
        content="I prefer boutique hotels in Paris."
    )
)

print(response.msgs[0].content)

Run python camel_mem0_demo.py (or the snippet above in a REPL). You should see the agent respond and the memory persisted to Mem0. Re-running with a new prompt should include the stored preference.

Verify the integration

  • Mem0 dashboard shows new memories under agent_id=travel_agent and user_id=alice.
  • mem0_store.load() returns the records you just wrote.
  • Camel agent replies reference prior user preferences on subsequent runs.

Troubleshooting

  • Missing MEM0_API_KEY — set export MEM0_API_KEY="sk-..." or pass api_key into Mem0Storage.
  • No memories returned — ensure agent_id/user_id in your query match what you used when writing.
  • Network errors to Mem0 — if self-hosting, set MEM0_BASE_URL to your deployment URL.

Memory types in Mem0

Try LangChain next

Was this page helpful?

YesNo

Suggest edits Raise issue

Agno\ \ Previous OpenClaw\ \ Next

Ctrl+I

Assistant

Responses are generated using AI and may contain mistakes.

Suggestions

How do I create a Mem0 storage?What are the required prerequisites?How do I set up Mem0 with Camel?

Contact support

SOP Documentation Site for Mem0