{"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."}]},"search_vec":"'agent':6,40 'ai':5 'assist':8 'break':34 'chang':35 'class':22,29 'distinct':18 'format':38 'host':26 'import':14 'introduc':33 'layer':3 'llm':41 'manag':30 'mem0':1,16 'mem0ai':12 'memori':2,21,39 'memorycli':28 'mode':20 'oss':23,44 'packag':10 'person':43 'platform':31 'pypi':9 'python':42 'respons':37 'self':25 'self-host':24 'two':17 'usag':19 'v1.0.0':32","created_at":"2026-03-16T04:39:09.011572+00:00","updated_at":"2026-04-16T16:29:42.270071+00:00","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,"quickstart_score":80,"quickstart_tag":"verified","pypi_latest":"2.0.4","cli_name":"","cli_version":null,"type":"library","homepage":"https://mem0.ai","github":null,"docs":null,"changelog":null,"pypi":"https://pypi.org/project/mem0ai/","npm":null,"openapi_spec":null,"status_page":null,"smithery":null,"categories":["llm-agents","ai-ml","database"],"base_url":null,"auth_type":null,"provenance":{"verified_status":"passing","verified_at":"2026-06-27","last_verified":"2026-06-27","next_check":"2026-07-27","install_tag":"verified"}}