Skip to content
AIRepoHub

mem0

by mem0ai

Memory layer that gives AI agents and apps persistent context.

Developer ToolsAI AgentsPythonApache 2.0 licenseLibrary
Stars
69,438
stars
Forks
8.3k
forks
Last push
today
Activity
Active
mem0: quick start
# Install the Python library$ pip install mem0ai# Or the JavaScript SDK$ npm install mem0ai

Commands from the project's README. Run them after installing (see below).

Overview

Understand mem0 in 60 seconds

What it does
Mem0 is a memory layer for AI assistants and agents. It stores facts from conversations, such as a user's preferences, and finds the relevant ones later so your assistant can give personal, consistent answers across sessions.
The problem it solves
Language models forget everything between conversations, and stuffing whole chat histories into prompts is slow and expensive. Mem0 extracts the important facts once and retrieves only the ones that matter for each new message.
Why choose it
Choose it for a ready-made memory API you can use as a Python or npm library, run as your own server with Docker, or use as a managed cloud service.
Who should use it
  • Developers building chatbots and AI assistants
  • Teams adding personalisation to support or agent apps
  • Builders using LangGraph or CrewAI who need memory
  • Anyone prototyping long-term memory for agents
Setup difficulty

You'll need:

  • Python (pip) or Node.js (npm)
  • An LLM and embedding model; OpenAI is the default
  • Docker for the self-hosted server

How mem0 works

Mem0 keeps memory at user, session and agent level. You call memory.add() with conversation messages and memory.search() with a query, and it returns the most relevant stored facts. By default it uses OpenAI's gpt-5-mini as the LLM and text-embedding-3-small for embeddings, and it supports many other providers.

There are three ways to use it: the open-source library for testing and prototypes, a self-hosted server started with Docker Compose that adds a dashboard and API keys, and the managed Mem0 Platform. An optional NLP extra adds BM25 keyword matching and entity extraction for hybrid search.

A mem0 CLI manages memories from the terminal, and agent skills teach coding assistants how to integrate Mem0. The project is Apache 2.0 licensed. Benchmark scores in the README are for the managed platform, which includes optimisations not in the open-source library.

Features

Key features

Multi-level memory

User, session and agent memory.

Hybrid search

Semantic, keyword and entity matching.

Python and JS SDKs

pip install mem0ai or npm install mem0ai.

Self-hosted server

Docker Compose stack with dashboard and auth.

CLI

Add and search memories from the terminal.

Integrations

LangGraph, CrewAI and a browser extension.

Strengths

  • Simple add and search API
  • Library, self-hosted or cloud
  • Works with many LLM providers
  • Apache 2.0 licensed

Limitations

  • Needs an LLM and embedding model, OpenAI by default
  • README benchmark numbers are for the managed platform
  • Self-hosted server needs Docker

Practical use cases

Personal assistant

Remember each user's preferences across chats.

Customer support

Recall past tickets and history.

Agent memory

Give LangGraph or CrewAI agents long-term memory.

Installation

Install mem0

Based on official documentation

Commands come from Mem0's README. AIRepoHub hasn't run them yet. View source

Prerequisites

  • Python or Node.js
  • An OpenAI API key, or another configured provider

Supported systems

  • Windows
  • macOS
  • Linux
  1. 1

    Install Mem0

    Shell
    pip install mem0ai
  2. 2

    Optional: add hybrid search support

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

    Install the SDK

    Shell
    npm install mem0ai
  1. 1

    From the repository's server folder, start the stack and create an admin

    Shell
    cd server && make bootstrap
  2. 2

    Or start it and finish setup in the browser wizard

    The wizard opens at http://localhost:3000.

    Shell
    cd server && docker compose up -d

Configuration and API keys

SettingWhat it's for
OPENAI_API_KEYOptionalNeeded for the default OpenAI LLM and embedding model; not needed if you configure another provider.

First run

  1. 1

    Try the CLI

    Shell
    npm install -g @mem0/climem0 initmem0 add "Prefers dark mode and vim keybindings" --user-id alicemem0 search "What does Alice prefer?" --user-id alice

mem0's documentation doesn't include sample output, so we don't show any. Expect the results in your terminal.

Your first project

Give a chatbot long-term memory in Python

Build a terminal chat that remembers what each user tells it.

Before you start

  • pip install mem0ai openai
  • OPENAI_API_KEY set
  1. 1

    Create the memory and a client

    Text
    from openai import OpenAIfrom mem0 import Memoryopenai_client = OpenAI()memory = Memory()
  2. 2

    Search memories before answering

    Text
    relevant = memory.search(query=message, filters={"user_id": user_id}, top_k=3)memories_str = "\n".join(f"- {e['memory']}" for e in relevant["results"])
  3. 3

    Answer with the memories in the system prompt, then save the exchange

    Text
    messages.append({"role": "assistant", "content": assistant_response})memory.add(messages, user_id=user_id)

What to expect

In later messages, the assistant's answers use facts the user mentioned earlier in the conversation.

Next steps

  • Install the nlp extra for hybrid search
  • Run the self-hosted server
  • Connect Mem0 to LangGraph or CrewAI

Costs and requirements

What it costs to run

Software
Free and open source under Apache 2.0.Free
Model usage
LLM and embedding calls are billed by your provider (OpenAI by default).Depends
Mem0 Platform
Optional managed cloud service.Depends

Troubleshooting

Common setup issues

Self-hosted server asks for auth after upgrading

Set ADMIN_API_KEY, register an admin in the wizard, or use AUTH_DISABLED=true for local development only.

Source: README.md

Keyword or entity search not working

Install mem0ai[nlp] and download en_core_web_sm.

Source: README.md

Errors about the API key

Set OPENAI_API_KEY or configure another LLM provider.

Source: README.md

Alternatives

Similar AI repositories