Mem0
raw JSON → 1.0.4 verified Tue May 12 auth: yes python install: verified quickstart: verified
Memory layer for AI agents and assistants. PyPI package is mem0ai but imports as mem0. Two distinct usage modes: Memory class (OSS, self-hosted) and MemoryClient class (managed platform). v1.0.0 introduced breaking changes to response format.
pip install mem0ai Common errors
error ModuleNotFoundError: No module named 'mem0' ↓
cause The Python package is named `mem0ai` on PyPI, but the import name within Python code is `mem0`.
fix
Ensure you have installed the correct package using
pip install mem0ai and then import it as import mem0 or from mem0 import Memory, MemoryClient. error ValueError: The v1.0 API format is no longer supported in mem0ai 1.0.0+. Please use v1.1 format which returns a dict with 'results' key. ↓
cause This error occurs because mem0ai v1.0.0 introduced breaking changes, removing support for the v1.0 API format and standardizing all responses to a dictionary with a 'results' key.
fix
Update your code to use the v1.1 API format. This typically involves removing
version and output_format parameters from method calls and accessing results via result['results'] instead of treating the response directly as a list. error AttributeError: 'Memory' object has no attribute 'version' ↓
cause This is typically caused by attempting to access or pass a `version` parameter to `Memory` or `MemoryClient` methods, which was removed in mem0ai v1.0.0. Other `AttributeError`s may arise from accessing removed parameters or properties that were part of pre-v1.0.0 API.
fix
Remove the
version parameter from all Memory and MemoryClient method calls and configurations. Refer to the migration guide for other potential parameter removals and response format changes. error ImportError: cannot import name 'MemoryClient' from partially initialized module 'mem0' (most likely due to a circular import) ↓
cause This specific ImportError usually means you have named one of your local Python files `mem0.py`, creating a circular import conflict with the installed `mem0` library.
fix
Rename your local
mem0.py file to something else to avoid conflict with the library's import name. error HTTP error occurred: Client error '400 Bad Request' for url 'https://api.mem0.ai/v1/memories/' Failed to add to long term memory: API request failed: {"error":"At least one of the filters: agent_id, user_id, app_id, run_id is required!"} ↓
cause When using `MemoryClient` with the managed platform, certain API calls (like adding memories) require specific identifiers such as `user_id`, `agent_id`, `app_id`, or `run_id` for proper scoping and data isolation.
fix
Ensure you are passing at least one of the required identification parameters (e.g.,
user_id) when making API calls that store or retrieve memories through the MemoryClient. Warnings
breaking v1.0 changed all response formats. add() and get_all() now return a dict with a 'results' key, not a flat list. Code iterating directly over the return value breaks with TypeError. ↓
fix Access results via memory.add(...)["results"] and memory.get_all(...)["results"].
breaking output_format='v1.0' is removed server-side. Passing it raises DeprecationWarning then 400 Bad Request from the platform API. ↓
fix Remove all output_format parameters. v1.1 format is now the only format.
gotcha Package name is mem0ai but import name is mem0. pip install mem0ai, then from mem0 import Memory. ↓
fix pip install mem0ai && from mem0 import Memory
gotcha MemoryClient.add() defaults to async_mode=True in v1.0+. Calling search() immediately after add() may return empty results as memory has not yet been stored. ↓
fix Pass async_mode=False to block until memory is stored before querying.
gotcha OSS Memory() with no config calls OpenAI by default. Fails with AuthenticationError if OPENAI_API_KEY is not set. ↓
fix Set OPENAI_API_KEY or pass a config dict to Memory() specifying an alternative LLM provider.
gotcha Graph memory features require pip install mem0ai[graph]. Importing graph-related classes without this extra raises ImportError. ↓
fix pip install mem0ai[graph]
breaking Installation fails when building 'psycopg2' from source due to 'pg_config executable not found'. This typically occurs in environments like Alpine Linux that lack PostgreSQL development headers, which are required to compile psycopg2. ↓
fix Ensure PostgreSQL development headers are installed in the environment (e.g., `apk add postgresql-dev` on Alpine Linux) or, if possible, use `psycopg2-binary` instead of `psycopg2` to avoid building from source.
Install
pip install mem0ai[graph] Install compatibility verified last tested: 2026-05-12
python os / libc variant status wheel install import disk
3.10 alpine (musl) mem0ai - - 5.51s 181.4M
3.10 alpine (musl) graph - - 5.81s 183.1M
3.10 slim (glibc) mem0ai - - 3.49s 172M
3.10 slim (glibc) graph - - 3.72s 173M
3.11 alpine (musl) mem0ai - - 6.60s 197.0M
3.11 alpine (musl) graph - - 6.26s 198.9M
3.11 slim (glibc) mem0ai - - 4.75s 187M
3.11 slim (glibc) graph - - 4.80s 188M
3.12 alpine (musl) mem0ai - - 5.75s 183.8M
3.12 alpine (musl) graph - - 5.43s 185.6M
3.12 slim (glibc) mem0ai - - 4.73s 173M
3.12 slim (glibc) graph - - 4.89s 175M
3.13 alpine (musl) mem0ai - - 5.26s 183.0M
3.13 alpine (musl) graph - - 5.04s 184.8M
3.13 slim (glibc) mem0ai - - 4.46s 173M
3.13 slim (glibc) graph - - 4.42s 174M
3.9 alpine (musl) mem0ai - - 4.80s 187.1M
3.9 alpine (musl) graph - - 4.92s 189.1M
3.9 slim (glibc) mem0ai - - 3.74s 180M
3.9 slim (glibc) graph - - 3.96s 182M
Imports
- Memory wrong
from mem0ai import Memorycorrectfrom mem0 import Memory - MemoryClient wrong
from mem0 import Memorycorrectfrom mem0 import MemoryClient
Quickstart verified last tested: 2026-05-12
from mem0 import Memory
memory = Memory() # requires OPENAI_API_KEY by default
memory.add(
[{"role": "user", "content": "I like basketball."}],
user_id="alice"
)
results = memory.search(query="sports", user_id="alice", limit=3)
for r in results["results"]:
print(r["memory"])