{"id":46,"library":"mem0ai","title":"Mem0","description":"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.","status":"active","version":"1.0.4","language":"python","source_language":"en","source_url":"https://github.com/mem0ai/mem0","tags":["memory","agents","llm","python","personalization","oss"],"install":[{"cmd":"pip install mem0ai","lang":"bash","label":"Python (core)"},{"cmd":"pip install mem0ai[graph]","lang":"bash","label":"Python (with graph memory support)"}],"dependencies":[{"reason":"Default LLM backend for OSS Memory class. Required unless configured otherwise.","package":"openai","optional":false},{"reason":"Default vector store for OSS Memory class.","package":"qdrant-client","optional":true},{"reason":"Required for graph memory. Only needed with mem0ai[graph].","package":"neo4j","optional":true}],"imports":[{"note":"Package is mem0ai but module is mem0. Common codegen error.","wrong":"from mem0ai import Memory","symbol":"Memory","correct":"from mem0 import Memory"},{"note":"MemoryClient is for the managed platform (needs MEM0_API_KEY). Memory is for OSS self-hosted. They are not interchangeable.","wrong":"from mem0 import Memory","symbol":"MemoryClient","correct":"from mem0 import MemoryClient"}],"quickstart":{"code":"from mem0 import Memory\n\nmemory = Memory()  # requires OPENAI_API_KEY by default\n\nmemory.add(\n    [{\"role\": \"user\", \"content\": \"I like basketball.\"}],\n    user_id=\"alice\"\n)\n\nresults = memory.search(query=\"sports\", user_id=\"alice\", limit=3)\nfor r in results[\"results\"]:\n    print(r[\"memory\"])","lang":"python","description":"OSS self-hosted usage with Memory class. For platform usage, replace Memory() with MemoryClient(api_key=...)."},"warnings":[{"fix":"Access results via memory.add(...)[\"results\"] and memory.get_all(...)[\"results\"].","message":"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.","severity":"breaking","affected_versions":"< 1.0.0"},{"fix":"Remove all output_format parameters. v1.1 format is now the only format.","message":"output_format='v1.0' is removed server-side. Passing it raises DeprecationWarning then 400 Bad Request from the platform API.","severity":"breaking","affected_versions":"< 1.0.0"},{"fix":"pip install mem0ai && from mem0 import Memory","message":"Package name is mem0ai but import name is mem0. pip install mem0ai, then from mem0 import Memory.","severity":"gotcha","affected_versions":"all"},{"fix":"Pass async_mode=False to block until memory is stored before querying.","message":"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.","severity":"gotcha","affected_versions":">= 1.0.0"},{"fix":"Set OPENAI_API_KEY or pass a config dict to Memory() specifying an alternative LLM provider.","message":"OSS Memory() with no config calls OpenAI by default. Fails with AuthenticationError if OPENAI_API_KEY is not set.","severity":"gotcha","affected_versions":"all"},{"fix":"pip install mem0ai[graph]","message":"Graph memory features require pip install mem0ai[graph]. Importing graph-related classes without this extra raises ImportError.","severity":"gotcha","affected_versions":"all"},{"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.","message":"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.","severity":"breaking","affected_versions":"all"}],"env_vars":{"optional":[{"name":"MEM0_API_KEY","note":"Required only for MemoryClient (managed platform). Not used by OSS Memory class."}],"required":[{"name":"OPENAI_API_KEY","note":"Required for OSS Memory class with default config. Not needed if using a custom LLM backend."}]},"last_verified":"2026-05-12T05:51:18.729Z","next_check":"2026-04-01T00:00:00.000Z","problems":[{"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`.","cause":"The Python package is named `mem0ai` on PyPI, but the import name within Python code is `mem0`.","error":"ModuleNotFoundError: No module named 'mem0'"},{"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.","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.","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."},{"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.","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.","error":"AttributeError: 'Memory' object has no attribute 'version'"},{"fix":"Rename your local `mem0.py` file to something else to avoid conflict with the library's import name.","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.","error":"ImportError: cannot import name 'MemoryClient' from partially initialized module 'mem0' (most likely due to a circular import)"},{"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`.","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.","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!\"}"}],"ecosystem":"pypi","meta_description":null,"install_score":95,"install_tag":"verified","quickstart_score":80,"quickstart_tag":"verified","pypi_latest":null,"install_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"installs cleanly on critical runtimes, fast import, recently tested","results":[{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5.51,"mem_mb":47.5,"disk_size":"181.4M"},{"runtime":"python:3.10-alpine","python_version":"3.10","os_libc":"alpine (musl)","variant":"graph","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5.81,"mem_mb":48,"disk_size":"183.1M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":3.49,"mem_mb":40.7,"disk_size":"172M"},{"runtime":"python:3.10-slim","python_version":"3.10","os_libc":"slim (glibc)","variant":"graph","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":3.72,"mem_mb":41,"disk_size":"173M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":6.6,"mem_mb":49.4,"disk_size":"197.0M"},{"runtime":"python:3.11-alpine","python_version":"3.11","os_libc":"alpine (musl)","variant":"graph","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":6.26,"mem_mb":49.7,"disk_size":"198.9M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":4.75,"mem_mb":42.7,"disk_size":"187M"},{"runtime":"python:3.11-slim","python_version":"3.11","os_libc":"slim (glibc)","variant":"graph","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":4.8,"mem_mb":42.9,"disk_size":"188M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5.75,"mem_mb":48.7,"disk_size":"183.8M"},{"runtime":"python:3.12-alpine","python_version":"3.12","os_libc":"alpine (musl)","variant":"graph","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5.43,"mem_mb":49,"disk_size":"185.6M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":4.73,"mem_mb":42.1,"disk_size":"173M"},{"runtime":"python:3.12-slim","python_version":"3.12","os_libc":"slim (glibc)","variant":"graph","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":4.89,"mem_mb":42.3,"disk_size":"175M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5.26,"mem_mb":49.6,"disk_size":"183.0M"},{"runtime":"python:3.13-alpine","python_version":"3.13","os_libc":"alpine (musl)","variant":"graph","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":5.04,"mem_mb":49.6,"disk_size":"184.8M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":4.46,"mem_mb":42.6,"disk_size":"173M"},{"runtime":"python:3.13-slim","python_version":"3.13","os_libc":"slim (glibc)","variant":"graph","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":4.42,"mem_mb":42.8,"disk_size":"174M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":4.8,"mem_mb":46.9,"disk_size":"187.1M"},{"runtime":"python:3.9-alpine","python_version":"3.9","os_libc":"alpine (musl)","variant":"graph","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":4.92,"mem_mb":47.1,"disk_size":"189.1M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"default","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":3.74,"mem_mb":40.3,"disk_size":"180M"},{"runtime":"python:3.9-slim","python_version":"3.9","os_libc":"slim (glibc)","variant":"graph","exit_code":0,"wheel_type":null,"failure_reason":null,"install_time_s":null,"import_time_s":3.96,"mem_mb":40.5,"disk_size":"182M"}]},"quickstart_checks":{"last_tested":"2026-05-12","tag":"verified","tag_description":"quickstart runs on critical runtimes, recently tested","results":[{"runtime":"python:3.10-alpine","exit_code":0},{"runtime":"python:3.10-slim","exit_code":0},{"runtime":"python:3.11-alpine","exit_code":0},{"runtime":"python:3.11-slim","exit_code":0},{"runtime":"python:3.12-alpine","exit_code":0},{"runtime":"python:3.12-slim","exit_code":0},{"runtime":"python:3.13-alpine","exit_code":0},{"runtime":"python:3.13-slim","exit_code":0},{"runtime":"python:3.9-alpine","exit_code":0},{"runtime":"python:3.9-slim","exit_code":0}]}}