What it is
Mem0 ("mem-zero") adds an intelligent memory layer to AI assistants and agents so they can remember user preferences, adapt to individual needs, and learn over time. It retains User, Session, and Agent state and is offered as a Python/npm library, a self-hosted server, or a managed cloud platform. It also ships a CLI and agent skills for coding assistants.
Who it's for
- Developers building AI assistants, customer support chatbots, or autonomous agents that need persistent memory
- Teams that want to self-host a memory server on their own infrastructure
- Teams wanting a zero-ops managed memory platform
- Developers using AI coding assistants (Claude Code, Codex, Cursor, Windsurf, etc.) who want Mem0 integration skills
Requirements
Requirements
- An LLM is required; default is gpt-5-mini from OpenAI (other LLMs are supported)
- Default embedding model is text-embedding-3-small from OpenAI
- Self-hosted server setup uses docker compose
- For hybrid search with BM25 and entity extraction, install the nlp extra and the spaCy en_core_web_sm model
- Self-hosted auth is on by default
Setup
Install the Python library
Install the library for testing and prototyping.
bashpip install mem0aiOptional NLP support for hybrid search
Install with NLP support for BM25 keyword matching and entity extraction.
bashpip install mem0ai[nlp] python -m spacy download en_core_web_smInstall the npm SDK
Install the SDK via npm.
bashnpm install mem0aiRun the self-hosted server
Recommended: one command starts the stack, creates an admin, and issues the first API key. Alternatively, start the stack and finish setup via the browser wizard at http://localhost:3000.
bash# Recommended: one command — start the stack, create an admin, issue the first API key. cd server && make bootstrap # Manual: start the stack and finish setup via the browser wizard. cd server && docker compose up -d # http://localhost:3000Install the CLI
Manage memories from your terminal.
bashnpm install -g @mem0/cli # or: pip install mem0-cli mem0 init mem0 add "Prefers dark mode and vim keybindings" --user-id alice mem0 search "What does Alice prefer?" --user-id alice
Examples
Chat loop with memory retrieval and storage
pythonfrom 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_responseWhat it does: Searches memories for the user, injects them into the system prompt, gets an OpenAI response, then stores the conversation as new memories.
Agent sign-up and first memory via CLI
bash# 1. Install
npm install -g @mem0/cli # or: pip install mem0-cli
# 2. Sign up as an agent (replace `claude-code` with your name)
mem0 init --agent --agent-caller claude-code
# 3. Add a memory
mem0 add "I am using mem0"
# 4. Search
mem0 search "am I using mem0"What it does: Lets an AI agent get a working Mem0 API key and add and search memories in four commands; the human owner can later claim the account with mem0 init --email <their-email>.
Install agent skills for a coding assistant
bashnpx skills add https://github.com/mem0ai/mem0 --skill mem0
npx skills add https://github.com/mem0ai/mem0 --skill mem0-cli
npx skills add https://github.com/mem0ai/mem0 --skill mem0-vercel-ai-sdkWhat it does: Reference skills that load Mem0 SDK knowledge into the AI coding assistant's context.
Pros & cons
Pros
- Pro:Multiple deployment options: library, self-hosted server (docker compose), or managed cloud platform
- Pro:Retrieval combines semantic, BM25 keyword, and entity matching, with temporal reasoning; benchmark results are published and the evaluation framework is open-sourced
- Pro:Supports a variety of LLMs and embedding models rather than only the OpenAI defaults
- Pro:Includes a CLI, Python and npm SDKs, and agent skills for coding assistants, plus LangGraph and CrewAI integrations
Cons
- Con:Requires an LLM to function, with OpenAI models as the defaults
- Con:Published benchmark scores reflect the managed platform's proprietary optimizations; open-source users should expect only directionally similar gains
- Con:Self-hosted auth is on by default, so upgrading from a pre-auth build requires extra steps (ADMIN_API_KEY, wizard, or AUTH_DISABLED for local dev)
Images
