Mem0

RAG & Memory 💻 Python ⚖️ Apache-2.0 🟢 Actively maintained
64.7k stars

Mem0 is an intelligent memory layer for AI assistants and agents that enables personalized interactions by remembering user preferences and adapting over time. It solves the problem of context loss in AI conversations by providing multi-level memory (user, session, agent) with a developer-friendly API. It is for developers building AI assistants, customer support chatbots, healthcare applications, and other autonomous systems.

✨ Key features

  • Multi-level memory: user, session, and agent state
  • Single-pass ADD-only extraction with entity linking
  • Multi-signal retrieval: semantic, BM25, and entity matching
  • Temporal reasoning for time-aware retrieval
  • Cross-platform SDKs: Python, npm, CLI
  • Self-hosted server and cloud platform options

🎯 Use cases

  • Build AI assistants that remember user preferences across conversations
  • Create customer support chatbots that recall past tickets and user history
  • Develop healthcare applications that track patient preferences and history
  • Personalize productivity tools and gaming environments based on user behavior

📦 Installation

🧰 Requirements: Requires an LLM (default OpenAI gpt-5-mini) and an embedding model (default text-embedding-3-small). Python 3.x or Node.js for SDKs. Optional API keys for cloud platform.

pip install mem0ai

For enhanced hybrid search with BM25 and entity extraction:

pip install mem0ai[nlp]
python -m spacy download en_core_web_sm

Install via npm:

npm install mem0ai

For CLI:

npm install -g @mem0/cli   # or: pip install mem0-cli

🚀 Usage

from openai import OpenAI
from mem0 import Memory

openai_client = OpenAI()
memory = Memory()

def chat_with_memories(message: str, user_id: str = "default_user") -> str:
    # Retrieve relevant memories
    relevant_memories = memory.search(query=message, filters={"user_id": user_id}, top_k=3)
    memories_str = "\n".join(f"- {entry['memory']}" for entry in relevant_memories["results"])

    # Generate Assistant response
    system_prompt = f"You are a helpful AI. Answer the question based on query and memories.\nUser Memories:\n{memories_str}"
    messages = [{"role": "system", "content": system_prompt}, {"role": "user", "content": message}]
    response = openai_client.chat.completions.create(model="gpt-5-mini", messages=messages)
    assistant_response = response.choices[0].message.content

    # Create new memories from the conversation
    messages.append({"role": "assistant", "content": assistant_response})
    memory.add(messages, user_id=user_id)

    return assistant_response

print(chat_with_memories("Hi, I'm Alice"))

⚠️ Good to know

Open-source SDK may not achieve identical benchmark scores as the managed platform due to proprietary optimizations.

❓ FAQ

What LLMs does Mem0 support?

Mem0 requires an LLM to function, with gpt-5-mini from OpenAI as the default, but it supports a variety of LLMs as documented in the Supported LLMs page.

Can I use Mem0 without a cloud account?

Yes, you can use the library locally with pip install mem0ai, or self-host the server with docker compose. The cloud platform requires signing up at app.mem0.ai.

How do I install the CLI?

Install the CLI globally via npm: npm install -g @mem0/cli, or via pip: pip install mem0-cli.

What is the difference between the library and the self-hosted server?

The library is best for testing and prototyping, while the self-hosted server is for teams running on their own infrastructure and includes a dashboard and auth.

📊 Repository

Stars★ 64,738
Forks🍴 7,576
Open issues🐛 724
Last commit🕒 Sep 4, 2026
Created📅 Jun 2023
Language💻 Python
License⚖️ Apache-2.0
Websitemem0.ai

🤖 Overview, features, install steps and FAQ were generated from the project's README on Sep 4, 2026. Always check the original source before running commands.