| --- |
| title: API Reference Changes |
| description: "Comprehensive reference of all API changes between Mem0 v0.x and v1.0.0 Beta, organized by component and method." |
| icon: "code" |
| iconType: "solid" |
| --- |
|
|
| |
|
|
| This page documents all API changes between Mem0 v0.x and v1.0.0 Beta, organized by component and method. |
|
|
| |
|
|
| |
|
|
| |
| ```python |
| from mem0 import Memory |
|
|
| |
| m = Memory() |
|
|
| |
| config = { |
| "version": "v1.0", |
| "vector_store": {...} |
| } |
| m = Memory.from_config(config) |
| ``` |
|
|
| |
| ```python |
| from mem0 import Memory |
|
|
| |
| m = Memory() |
|
|
| |
| config = { |
| "version": "v1.1", |
| "vector_store": {...}, |
| |
| "reranker": { |
| "provider": "cohere", |
| "config": {...} |
| } |
| } |
| m = Memory.from_config(config) |
| ``` |
|
|
| |
|
|
| |
| ```python |
| def add( |
| self, |
| messages, |
| user_id: str = None, |
| agent_id: str = None, |
| run_id: str = None, |
| metadata: dict = None, |
| filters: dict = None, |
| output_format: str = None, |
| version: str = None |
| ) -> Union[List[dict], dict] |
| ``` |
|
|
| |
| ```python |
| def add( |
| self, |
| messages, |
| user_id: str = None, |
| agent_id: str = None, |
| run_id: str = None, |
| metadata: dict = None, |
| filters: dict = None, |
| infer: bool = True |
| ) -> dict |
| ``` |
|
|
| |
|
|
| | Parameter | v0.x | v1.0.0 | Change | |
| |-----------|------|-----------|---------| |
| | `messages` | ✅ | ✅ | Unchanged | |
| | `user_id` | ✅ | ✅ | Unchanged | |
| | `agent_id` | ✅ | ✅ | Unchanged | |
| | `run_id` | ✅ | ✅ | Unchanged | |
| | `metadata` | ✅ | ✅ | Unchanged | |
| | `filters` | ✅ | ✅ | Unchanged | |
| | `output_format` | ✅ | ❌ | **REMOVED** | |
| | `version` | ✅ | ❌ | **REMOVED** | |
| | `infer` | ❌ | ✅ | **NEW** | |
|
|
| |
|
|
| **v0.x Response (variable format):** |
| ```python |
| |
| [ |
| { |
| "id": "mem_123", |
| "memory": "User loves pizza", |
| "event": "ADD" |
| } |
| ] |
|
|
| |
| { |
| "results": [ |
| { |
| "id": "mem_123", |
| "memory": "User loves pizza", |
| "event": "ADD" |
| } |
| ] |
| } |
| ``` |
|
|
| **v1.0.0 Response (standardized):** |
| ```python |
| |
| { |
| "results": [ |
| { |
| "id": "mem_123", |
| "memory": "User loves pizza", |
| "metadata": {...}, |
| "event": "ADD" |
| } |
| ] |
| } |
| ``` |
|
|
| |
|
|
| |
| ```python |
| def search( |
| self, |
| query: str, |
| user_id: str = None, |
| agent_id: str = None, |
| run_id: str = None, |
| limit: int = 100, |
| filters: dict = None, |
| output_format: str = None, |
| version: str = None |
| ) -> Union[List[dict], dict] |
| ``` |
|
|
| |
| ```python |
| def search( |
| self, |
| query: str, |
| user_id: str = None, |
| agent_id: str = None, |
| run_id: str = None, |
| limit: int = 100, |
| filters: dict = None, |
| rerank: bool = True |
| ) -> dict |
| ``` |
|
|
| |
|
|
| **v0.x Filters (basic):** |
| ```python |
| |
| filters = { |
| "category": "food", |
| "user_id": "alice" |
| } |
| ``` |
|
|
| **v1.0.0 Filters (enhanced):** |
| ```python |
| |
| filters = { |
| "AND": [ |
| {"category": "food"}, |
| {"score": {"gte": 0.8}}, |
| { |
| "OR": [ |
| {"priority": "high"}, |
| {"urgent": True} |
| ] |
| } |
| ] |
| } |
|
|
| |
| filters = { |
| "score": {"gt": 0.5}, |
| "priority": {"gte": 5}, |
| "rating": {"lt": 3}, |
| "confidence": {"lte": 0.9}, |
| "status": {"eq": "active"}, |
| "archived": {"ne": True}, |
| "tags": {"in": ["work", "personal"]}, |
| "category": {"nin": ["spam", "deleted"]} |
| } |
| ``` |
|
|
| |
|
|
| |
| ```python |
| def get_all( |
| self, |
| user_id: str = None, |
| agent_id: str = None, |
| run_id: str = None, |
| filters: dict = None, |
| output_format: str = None, |
| version: str = None |
| ) -> Union[List[dict], dict] |
| ``` |
|
|
| |
| ```python |
| def get_all( |
| self, |
| user_id: str = None, |
| agent_id: str = None, |
| run_id: str = None, |
| filters: dict = None |
| ) -> dict |
| ``` |
|
|
| |
|
|
| |
| ```python |
| |
| def update( |
| self, |
| memory_id: str, |
| data: str |
| ) -> dict |
| ``` |
|
|
| |
|
|
| |
| ```python |
| |
| def delete( |
| self, |
| memory_id: str |
| ) -> dict |
| ``` |
|
|
| |
|
|
| |
|
|
| **Before:** calling `delete_all()` with no filters silently deleted **all memories in the project**. |
|
|
| **After:** |
| - No filters → raises a validation error (prevents accidental full-project wipe). |
| - Concrete ID (e.g. `user_id="alice"`) → deletes memories for that entity (unchanged). |
| - `"*"` for a filter → deletes all memories for that entity type across the project (new). |
| - All four filters set to `"*"` → explicit full project wipe (new, requires opt-in on every parameter). |
|
|
| This change replaces the silent full-project delete (triggered by an empty or missing filter) with a validation error, and introduces `"*"` wildcards as the intentional path for bulk deletion. |
|
|
| ```python |
| |
| m.delete_all() |
| m.delete_all(user_id="alice") |
|
|
| |
| m.delete_all() |
| m.delete_all(user_id="alice") |
| m.delete_all(user_id="*") |
| m.delete_all(user_id="*", agent_id="*", app_id="*", run_id="*") |
| ``` |
|
|
| |
|
|
| |
|
|
| |
| ```python |
| from mem0 import MemoryClient |
|
|
| client = MemoryClient(api_key="your-key") |
|
|
| |
| result = client.add("content", user_id="alice", async_mode=True) |
| ``` |
|
|
| |
| ```python |
| from mem0 import MemoryClient |
|
|
| client = MemoryClient(api_key="your-key") |
|
|
| |
| result = client.add("content", user_id="alice") |
|
|
| |
| result = client.add("content", user_id="alice", async_mode=False) |
| ``` |
|
|
| |
|
|
| |
|
|
| |
| ```python |
| config = { |
| "vector_store": {...}, |
| "llm": {...}, |
| "embedder": {...}, |
| "graph_store": {...}, |
| "version": "v1.0", |
| "history_db_path": "...", |
| "custom_fact_extraction_prompt": "..." |
| } |
| ``` |
|
|
| |
| ```python |
| config = { |
| "vector_store": {...}, |
| "llm": {...}, |
| "embedder": {...}, |
| "graph_store": {...}, |
| "reranker": { |
| "provider": "cohere", |
| "config": {...} |
| }, |
| "version": "v1.1", |
| "history_db_path": "...", |
| "custom_fact_extraction_prompt": "...", |
| "custom_update_memory_prompt": "..." |
| } |
| ``` |
|
|
| |
|
|
| |
| ```python |
| |
| "reranker": { |
| "provider": "cohere", |
| "config": { |
| "model": "rerank-english-v3.0", |
| "api_key": "your-api-key", |
| "top_k": 10 |
| } |
| } |
|
|
| |
| "reranker": { |
| "provider": "sentence_transformer", |
| "config": { |
| "model": "cross-encoder/ms-marco-MiniLM-L-6-v2", |
| "device": "cuda" |
| } |
| } |
|
|
| |
| "reranker": { |
| "provider": "huggingface", |
| "config": { |
| "model": "BAAI/bge-reranker-base", |
| "device": "cuda" |
| } |
| } |
|
|
| |
| "reranker": { |
| "provider": "llm_reranker", |
| "config": { |
| "llm": { |
| "provider": "openai", |
| "config": { |
| "model": "gpt-4", |
| "api_key": "your-api-key" |
| } |
| } |
| } |
| } |
| ``` |
|
|
| |
|
|
| |
|
|
| |
| ```python |
| |
| try: |
| result = m.add("content", user_id="alice", version="v1.0") |
| except Exception as e: |
| print(f"Error: {e}") |
| ``` |
|
|
| |
| ```python |
| |
| try: |
| result = m.add("content", user_id="alice") |
| except ValueError as e: |
| if "v1.0 API format is no longer supported" in str(e): |
| |
| pass |
| elif "Invalid filter operator" in str(e): |
| |
| pass |
| except TypeError as e: |
| |
| pass |
| except Exception as e: |
| |
| pass |
| ``` |
|
|
| |
|
|
| |
|
|
| **v0.x (Lenient):** |
| ```python |
| |
| result = m.add("content", user_id="alice", unknown_param="value") |
| ``` |
|
|
| **v1.0.0 (Strict):** |
| ```python |
| |
| try: |
| result = m.add("content", user_id="alice", unknown_param="value") |
| except TypeError as e: |
| print(f"Invalid parameter: {e}") |
| ``` |
|
|
| |
|
|
| |
|
|
| |
| ```python |
| { |
| "id": "mem_123", |
| "memory": "User loves pizza", |
| "user_id": "alice", |
| "metadata": {...}, |
| "created_at": "2024-01-01T00:00:00Z", |
| "updated_at": "2024-01-01T00:00:00Z", |
| "score": 0.95 |
| } |
| ``` |
|
|
| |
| ```python |
| { |
| "id": "mem_123", |
| "memory": "User loves pizza", |
| "user_id": "alice", |
| "agent_id": "assistant", |
| "run_id": "session_001", |
| "metadata": {...}, |
| "categories": ["food"], |
| "immutable": false, |
| "created_at": "2024-01-01T00:00:00Z", |
| "updated_at": "2024-01-01T00:00:00Z", |
| "score": 0.95, |
| "rerank_score": 0.98 |
| } |
| ``` |
|
|
| |
|
|
| |
|
|
| |
| ```python |
| from mem0 import Memory |
|
|
| m = Memory() |
|
|
| |
| result = m.add( |
| "I love pizza", |
| user_id="alice", |
| output_format="v1.1", |
| version="v1.0" |
| ) |
|
|
| |
| if isinstance(result, list): |
| memories = result |
| else: |
| memories = result.get("results", []) |
|
|
| for memory in memories: |
| print(memory["memory"]) |
| ``` |
|
|
| |
| ```python |
| from mem0 import Memory |
|
|
| m = Memory() |
|
|
| |
| result = m.add( |
| "I love pizza", |
| user_id="alice" |
| ) |
|
|
| |
| for memory in result["results"]: |
| print(memory["memory"]) |
| ``` |
|
|
| |
|
|
| |
| ```python |
| |
| results = m.search( |
| "food preferences", |
| user_id="alice", |
| filters={"category": "food"}, |
| output_format="v1.1" |
| ) |
| ``` |
|
|
| |
| ```python |
| |
| results = m.search( |
| "food preferences", |
| user_id="alice", |
| filters={ |
| "AND": [ |
| {"category": "food"}, |
| {"score": {"gte": 0.8}} |
| ] |
| }, |
| rerank=True |
| ) |
| ``` |
|
|
| |
|
|
| | Component | v0.x | v1.0.0 | Status | |
| |-----------|------|-----------|---------| |
| | `add()` method | Variable response | Standardized response | ⚠️ Breaking | |
| | `search()` method | Basic filtering | Enhanced filtering + reranking | ⚠️ Breaking | |
| | `get_all()` method | Variable response | Standardized response | ⚠️ Breaking | |
| | Response format | Variable | Always `{"results": [...]}` | ⚠️ Breaking | |
| | Reranking | ❌ Not available | ✅ Full support | ✅ New feature | |
| | Advanced filtering | ❌ Basic only | ✅ Full operators | ✅ Enhancement | |
| | Error handling | Generic | Specific error types | ✅ Improvement | |
|
|
| <Info> |
| Use this reference to systematically update your codebase. Test each change thoroughly before deploying to production. |
| </Info> |