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.
Install & Compatibility
Where this runs
tested against v2.0.4 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
py 3.10
9/10 runs
9/10 runs
py 3.11
9/10 runs
9/10 runs
py 3.12
9/10 runs
9/10 runs
py 3.13
9/10 runs
9/10 runs
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
Memory
✓ from mem0 import Memory
✗ from mem0ai import Memory
Package is mem0ai but module is mem0. Common codegen error.
MemoryClient
✓ from mem0 import MemoryClient
✗ from mem0 import Memory
MemoryClient is for the managed platform (needs MEM0_API_KEY). Memory is for OSS self-hosted. They are not interchangeable.
OSS self-hosted usage with Memory class. For platform usage, replace Memory() with MemoryClient(api_key=...).
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"])
Errors
Common errors & fixes
ModuleNotFoundError: No module named 'mem0'
The Python package is named `mem0ai` on PyPI, but the import name within Python code is `mem0`.
fixEnsure you have installed the correct package using `pip install mem0ai` and then import it as `import mem0` or `from mem0 import Memory, MemoryClient`.
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.
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.
fixUpdate 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.
AttributeError: 'Memory' object has no attribute 'version'
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.
fixRemove 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.
ImportError: cannot import name 'MemoryClient' from partially initialized module 'mem0' (most likely due to a circular import)
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.
fixRename your local `mem0.py` file to something else to avoid conflict with the library's import name.
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!"}
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.
fixEnsure 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`.
Audit
Dependencies
openairequiredDefault LLM backend for OSS Memory class. Required unless configured otherwise.
qdrant-clientoptionalDefault vector store for OSS Memory class.
neo4joptionalRequired for graph memory. Only needed with mem0ai[graph].