The Memory Layer for AI Agents - Drop-in memory infrastructure for AI agents and apps. Context that persists. Built for production.
Python agentic-memoryagentic-memory-systemagentsaiai-agentschatgptgenaillmlong-term-memorymemorymemory-managementpythonragstate-management
[docs] Template moulding in docs/platform and index improvement (#3663)
Parth Sharma61faf7106454
diff --git a/docs/docs.json b/docs/docs.jsonindex 3d1865687..3a3cae859 100644--- a/docs/docs.json+++ b/docs/docs.json@@ -24,7 +24,9 @@{"group": "Start Here","icon": "home",- "pages": ["introduction"]+ "pages": [+ "introduction"+ ]}]},@@ -69,11 +71,12 @@},{"group": "Advanced Features",- "icon": "sparkles",+ "icon": "bolt","pages": ["platform/features/graph-memory","platform/features/graph-threshold","platform/features/advanced-retrieval",+ "platform/advanced-memory-operations","platform/features/criteria-retrieval","platform/features/contextual-add","platform/features/custom-instructions"@@ -103,7 +106,9 @@{"group": "Support & Troubleshooting","icon": "life-buoy",- "pages": ["platform/faqs", "platform/advanced-memory-operations"]+ "pages": [+ "platform/faqs"+ ]},{"group": "Migration Guide",@@ -274,7 +279,10 @@{"group": "Community & Support","icon": "users",- "pages": ["contributing/development", "contributing/documentation"]+ "pages": [+ "contributing/development",+ "contributing/documentation"+ ]}]},@@ -298,7 +306,9 @@{"group": "Overview","icon": "lightbulb",- "pages": ["examples"]+ "pages": [+ "examples"+ ]},{"group": "Getting Started Examples",@@ -355,7 +365,10 @@{"group": "Cloud & Infrastructure","icon": "cloud",- "pages": ["examples/aws_example", "examples/aws_neptune_analytics_hybrid_store"]+ "pages": [+ "examples/aws_example",+ "examples/aws_neptune_analytics_hybrid_store"+ ]}]},@@ -365,7 +378,9 @@{"group": "Overview","icon": "plug",- "pages": ["integrations"]+ "pages": [+ "integrations"+ ]},{"group": "Agent Frameworks",@@ -395,7 +410,9 @@{"group": "Cloud & Infrastructure","icon": "cloud",- "pages": ["integrations/aws-bedrock"]+ "pages": [+ "integrations/aws-bedrock"+ ]},{"group": "Developer Tools",@@ -417,7 +434,10 @@{"group": "Getting Started","icon": "rocket",- "pages": ["api-reference", "api-reference/organizations-projects"]+ "pages": [+ "api-reference",+ "api-reference/organizations-projects"+ ]},{"group": "Core Memory Operations",@@ -495,12 +515,16 @@{"group": "Changelog","icon": "rocket",- "pages": ["changelog"]+ "pages": [+ "changelog"+ ]},{"group": "Legacy Docs","icon": "archive",- "pages": ["v0x/introduction"]+ "pages": [+ "v0x/introduction"+ ]}],"icon": "clock"@@ -522,7 +546,11 @@{"group": "Getting Started","icon": "rocket",- "pages": ["v0x/introduction", "v0x/quickstart", "v0x/faqs"]+ "pages": [+ "v0x/introduction",+ "v0x/quickstart",+ "v0x/faqs"+ ]},{"group": "Core Concepts",diff --git a/docs/open-source/configuration.mdx b/docs/open-source/configuration.mdxindex 8fbaab2fd..d5e4271d2 100644--- a/docs/open-source/configuration.mdx+++ b/docs/open-source/configuration.mdx@@ -1,336 +1,173 @@----title: "Configuration"-description: "Configure Mem0 with custom LLMs, vector stores, embedders, and rerankers for production deployments"+title: "Configure the OSS Stack"+description: "Wire up Mem0 OSS with your preferred LLM, vector store, embedder, and reranker."icon: "sliders"-iconType: "solid"----Mem0 is highly configurable, allowing you to customize every component of your memory system. Choose from **51+ supported providers** across LLMs, vector databases, embedders, and rerankers.+# Configure Mem0 OSS Components-## Quick Start+<Info>+ **Prerequisites**+ - Python 3.10+ with `pip` available+ - Running vector database (e.g., Qdrant, Postgres + pgvector) or access credentials for a managed store+ - API keys for your chosen LLM, embedder, and reranker providers+</Info>-The simplest setup uses OpenAI defaults:+<Tip>+ Start from the <Link href="/open-source/python-quickstart">Python quickstart</Link> if you still need the base CLI and repository.+</Tip>-```python-import os-from mem0 import Memory+## Install dependencies-os.environ["OPENAI_API_KEY"] = "your-api-key"-m = Memory()+<Tabs>+ <Tab title="Python">+<Steps>+<Step title="Install Mem0 OSS">+```bash+pip install mem0ai```--For production or custom setups, configure specific components:--```python-from mem0 import Memory--config = {- "vector_store": {- "provider": "qdrant",- "config": {- "host": "localhost",- "port": 6333- }- },- "llm": {- "provider": "openai",- "config": {- "model": "gpt-4.1-nano-2025-04-14",- "temperature": 0.1- }- }-}--m = Memory.from_config(config)+</Step>+<Step title="Add provider SDKs (example: Qdrant + OpenAI)">+```bash+pip install qdrant-client openai```--## Configuration Components--Mem0 has four configurable components. Click any to see all supported providers and detailed configuration options.--<CardGroup cols={2}>-<Card title="LLMs" icon="message-bot" href="/components/llms/overview">-**17 providers** including OpenAI, Anthropic, Ollama, Groq, and more--Configure the language model for memory extraction and processing--</Card>--<Card title="Vector Databases" icon="hard-drive" href="/components/vectordbs/overview">-**25+ databases** including Qdrant, Chroma, Pinecone, Weaviate, and more--Choose where to store and retrieve memory embeddings--</Card>--<Card title="Embedding Models" icon="cube" href="/components/embedders/overview">-**9 providers** including OpenAI, HuggingFace, Ollama, and more--Select the model to convert memories into vector embeddings--</Card>--<Card title="Rerankers" icon="ranking-star" href="/components/rerankers/overview">-**4 models** including Cohere, Zero Entropy, and LLM-based--Improve search relevance by re-scoring retrieved memories--</Card>-</CardGroup>--## Configuration Recipes--### Production Setup with Qdrant--For production deployments, use a dedicated vector store:-+</Step>+</Steps>+ </Tab>+ <Tab title="Docker Compose"><Steps>-<Step title="Start Qdrant">+<Step title="Clone the repo and copy the compose file">```bash-docker pull qdrant/qdrant--docker run -p 6333:6333 -p 6334:6334 \- -v $(pwd)/qdrant_storage:/qdrant/storage:z \- qdrant/qdrant--````+git clone https://github.com/mem0ai/mem0.git+cd mem0/examples/docker-compose+```+</Step>+<Step title="Install dependencies for local overrides">+```bash+pip install -r requirements.txt+```</Step>+</Steps>+ </Tab>+</Tabs>-<Step title="Configure Mem0">+## Define your configuration++<Tabs>+ <Tab title="Python">+<Steps>+<Step title="Create a configuration dictionary">```python-import osfrom mem0 import Memory-os.environ["OPENAI_API_KEY"] = "your-api-key"-config = {"vector_store": {"provider": "qdrant",- "config": {- "host": "localhost",- "port": 6333,- }- }-}--m = Memory.from_config(config)-````--</Step>-</Steps>--### Fully Local Setup--Run Mem0 completely offline with Ollama (no external APIs):--<Card title="Local Setup with Ollama" icon="server" href="/examples/mem0-with-ollama">- Step-by-step guide to run Mem0 with local LLM and embeddings-</Card>--### Multi-Cloud Setup--Mix providers from different clouds:--```python-config = {- "llm": {- "provider": "azure_openai",- "config": {- "api_key": "azure-key",- "deployment_name": "gpt-4.1-nano-2025-04-14"- }+ "config": {"host": "localhost", "port": 6333},},- "vector_store": {- "provider": "pinecone",- "config": {- "api_key": "pinecone-key",- "index_name": "mem0"- }+ "llm": {+ "provider": "openai",+ "config": {"model": "gpt-4.1-mini", "temperature": 0.1},},"embedder": {"provider": "vertexai",- "config": {- "model": "textembedding-gecko@003"- }- }-}-```--### Graph Memory Setup--Enable relationship tracking with Neo4j:--```python-config = {- "graph_store": {- "provider": "neo4j",- "config": {- "url": "neo4j+s://your-instance.databases.neo4j.io",- "username": "neo4j",- "password": "your-password"- }- }+ "config": {"model": "textembedding-gecko@003"},+ },+ "reranker": {+ "provider": "cohere",+ "config": {"model": "rerank-english-v3.0"},+ },}-m = Memory.from_config(config)+memory = Memory.from_config(config)```--<Card title="Graph Memory Guide" icon="diagram-project" href="/open-source/features/graph-memory">- Learn how to use graph memory for relationship-based retrieval-</Card>--## Advanced Configuration--### Custom Prompts--Override default prompts for memory processing:--```python-config = {- "custom_fact_extraction_prompt": """- Extract key facts from the conversation.- Focus on: preferences, decisions, and context.- Output as a single sentence.- """,- "custom_update_memory_prompt": """- Update the existing memory with new information.- Preserve important context from the old memory.- """-}+</Step>+<Step title="Store secrets as environment variables">+```bash+export QDRANT_API_KEY="..."+export OPENAI_API_KEY="..."+export COHERE_API_KEY="..."```--<CardGroup cols={2}>-<Card title="Custom Fact Extraction" icon="sparkles" href="/open-source/features/custom-fact-extraction-prompt">-Customize how memories are extracted from conversations-</Card>--<Card title="Custom Memory Updates" icon="pen" href="/open-source/features/custom-update-memory-prompt">-Control how existing memories are modified-</Card>-</CardGroup>--### Reranking for Better Search--Add reranking to improve search relevance:--```python-config = {- "rerank": {- "provider": "cohere",- "config": {- "model": "rerank-english-v3.0",- "top_k": 5- }- }-}+</Step>+</Steps>+ </Tab>+ <Tab title="config.yaml">+<Steps>+<Step title="Create a `config.yaml` file">+```yaml+vector_store:+ provider: qdrant+ config:+ host: localhost+ port: 6333++llm:+ provider: azure_openai+ config:+ api_key: ${AZURE_OPENAI_KEY}+ deployment_name: gpt-4.1-mini++embedder:+ provider: ollama+ config:+ model: nomic-embed-text++reranker:+ provider: zero_entropy+ config:+ api_key: ${ZERO_ENTROPY_KEY}```-- <Card title="Reranker-Enhanced Search" icon="arrow-up-arrow-down" href="/open-source/features/reranker-search">- Learn how reranking improves memory search accuracy-</Card>--### History Database--Configure where operation history is stored:-+</Step>+<Step title="Load the config file at runtime">```python-config = {- "history_db_path": "/custom/path/to/history.db"-}-```--## All Configuration Options--<AccordionGroup>-<Accordion title="LLM Configuration">-| Parameter | Description | Provider |-|-----------------------|-----------------------------------------------|-------------------|-| `provider` | LLM provider (e.g., "openai", "anthropic") | All |-| `model` | Model to use | All |-| `temperature` | Temperature of the model (0.0-2.0) | All |-| `api_key` | API key to use | Most |-| `max_tokens` | Maximum tokens to generate | All |-| `top_p` | Nucleus sampling threshold | All |-| `top_k` | Top-k sampling parameter | Some |-| `ollama_base_url` | Base URL for Ollama API | Ollama |-| `openai_base_url` | Base URL for OpenAI API | OpenAI |-| `azure_kwargs` | Azure-specific initialization args | Azure OpenAI |--**See all 17 LLM providers:** [LLMs Overview](/components/llms/overview)--</Accordion>--<Accordion title="Vector Store Configuration">-Common parameters (provider-specific options vary):--| Parameter | Description | Example |-| ----------------- | -------------------------- | ----------- |-| `provider` | Vector store provider | "qdrant" |-| `host` | Host address | "localhost" |-| `port` | Port number | 6333 |-| `collection_name` | Collection/index name | "memories" |-| `api_key` | API key (for cloud stores) | "your-key" |--**See all 25+ vector stores:** [Vector Databases Overview](/components/vectordbs/overview)--</Accordion>--<Accordion title="Embedder Configuration">-| Parameter | Description | Default |-|-------------|---------------------------------|------------------------------|-| `provider` | Embedding provider | "openai" |-| `model` | Embedding model to use | "text-embedding-3-small" |-| `api_key` | API key for embedding service | None |--**See all 9 embedder providers:** [Embedders Overview](/components/embedders/overview)--</Accordion>--<Accordion title="Reranker Configuration">-| Parameter | Description | Example |-|-------------|---------------------------------|------------------------------|-| `provider` | Reranker provider | "cohere" |-| `model` | Reranker model to use | "rerank-english-v3.0" |-| `top_k` | Number of results to return | 5 |-| `api_key` | API key for reranker service | "your-key" |--**See all reranker options:** [Rerankers Overview](/components/rerankers/overview)--</Accordion>+from mem0 import Memory-<Accordion title="Graph Store Configuration">-| Parameter | Description | Example |-|-------------|---------------------------------|------------------------------|-| `provider` | Graph store provider | "neo4j" |-| `url` | Connection URL | "neo4j+s://..." |-| `username` | Authentication username | "neo4j" |-| `password` | Authentication password | "your-password" |+memory = Memory.from_config_file("config.yaml")+```+</Step>+</Steps>+ </Tab>+</Tabs>-**Learn more:** [Graph Memory Overview](/open-source/features/graph-memory)+<Info icon="check">+ Run `memory.add(["Remember my favorite cafe in Tokyo."], user_id="alex")` and then `memory.search("favorite cafe", user_id="alex")`. You should see the Qdrant collection populate and the reranker mark the memory as a top hit.+</Info>-</Accordion>+## Tune component settings-<Accordion title="General Configuration">-| Parameter | Description | Default |-|------------------|--------------------------------------|----------------------------|-| `history_db_path` | Path to the history database | "{mem0_dir}/history.db" |-| `custom_fact_extraction_prompt` | Custom prompt for memory extraction | None |-| `custom_update_memory_prompt` | Custom prompt for memory updates | None |-</Accordion>+<AccordionGroup>+ <Accordion title="Vector store collections">+ Name collections explicitly in production (`collection_name`) to isolate tenants and enable per-tenant retention policies.+ </Accordion>+ <Accordion title="LLM extraction temperature">+ Keep extraction temperatures ≤0.2 so advanced memories stay deterministic. Raise it only when you see missing facts.+ </Accordion>+ <Accordion title="Reranker depth">+ Limit `top_k` to 10–20 results; sending more adds latency without meaningful gains.+ </Accordion></AccordionGroup>-## Next Steps+<Warning>+ Mixing managed and self-hosted components? Make sure every outbound provider call happens through a secure network path. Managed rerankers often require outbound internet even if your vector store is on-prem.+</Warning>-<CardGroup cols={3}>-<Card title="Python Quickstart" icon="python" href="/open-source/python-quickstart">-Get started with the Python SDK-</Card>+## Quick recovery-<Card title="Self-Hosting Features" icon="server" href="/open-source/features/overview">- Explore OSS-specific capabilities-</Card>+- Qdrant connection errors → confirm port `6333` is exposed and API key (if set) matches.+- Empty search results → verify the embedder model name; a mismatch causes dimension errors.+- `Unknown reranker` → update the SDK (`pip install --upgrade mem0ai`) to load the latest provider registry.-<Card title="Examples" icon="book" href="/examples">-See configuration examples in action-</Card>+<CardGroup cols={2}>+ <Card+ title="Pick Providers"+ description="Review the LLM, vector store, embedder, and reranker catalogs."+ icon="sitemap"+ href="/components/llms/overview"+ />+ <Card+ title="Deploy with Docker Compose"+ description="Follow the end-to-end OSS deployment walkthrough."+ icon="server"+ href="/examples/mem0-with-ollama"+ /></CardGroup>diff --git a/docs/platform/advanced-memory-operations.mdx b/docs/platform/advanced-memory-operations.mdxindex 3f457f529..c8c3a14b6 100644--- a/docs/platform/advanced-memory-operations.mdx+++ b/docs/platform/advanced-memory-operations.mdx@@ -1,1388 +1,216 @@---title: Advanced Memory Operations-description: 'Comprehensive guide to advanced memory operations and features'-icon: "gear"-iconType: "solid"+description: "Run richer add/search/update/delete flows on the managed platform with metadata, rerankers, and per-request controls."----This guide covers advanced memory operations including complex filtering, batch operations, and detailed API usage. If you're just getting started, check out the [Quickstart](/platform/quickstart) first.+# Make Platform Memory Operations Smarter-## Advanced Memory Creation+<Info>+ **Prerequisites**+ - Platform workspace with API key+ - Python 3.10+ and Node.js 18++ - Async memories enabled in your dashboard (Settings → Memory Options)+</Info>-### Async Client (Python)+<Tip>+ Need a refresher on the core concepts first? Review the <Link href="/core-concepts/memory-operations/add">Add Memory</Link> overview, then come back for the advanced flow.+</Tip>-For asynchronous operations in Python, use the `AsyncMemoryClient`:+## Install and authenticate-```python Python-import os-from mem0 import AsyncMemoryClient--os.environ["MEM0_API_KEY"] = "your-api-key"-client = AsyncMemoryClient()--async def main():- messages = [- {"role": "user", "content": "I'm travelling to SF"}- ]- response = await client.add(messages, user_id="john")- print(response)--await main()+<Tabs>+ <Tab title="Python">+<Steps>+<Step title="Install the SDK with async extras">+```bash+pip install "mem0ai[async]"```--### Detailed Memory Creation Examples--#### Long-term memory with full context--<CodeGroup>--```python Python-messages = [- {"role": "user", "content": "Hi, I'm Alex. I'm a vegetarian and I'm allergic to nuts."},- {"role": "assistant", "content": "Hello Alex! I've noted that you're a vegetarian and have a nut allergy. I'll keep this in mind for any food-related recommendations or discussions."}-]--client.add(messages, user_id="alex", metadata={"food": "vegan"})+</Step>+<Step title="Export your API key">+```bash+export MEM0_API_KEY="sk-platform-..."```--```javascript JavaScript-const messages = [- {"role": "user", "content": "Hi, I'm Alex. I'm a vegetarian and I'm allergic to nuts."},- {"role": "assistant", "content": "Hello Alex! I've noted that you're a vegetarian and have a nut allergy. I'll keep this in mind for any food-related recommendations or discussions."}-];-client.add(messages, { user_id: "alex", metadata: { food: "vegan" } })- .then(response => console.log(response))- .catch(error => console.error(error));-```--```bash cURL-curl -X POST "https://api.mem0.ai/v1/memories/" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "messages": [- {"role": "user", "content": "Hi, I'm Alex. I'm a vegetarian and I'm allergic to nuts."},- {"role": "assistant", "content": "Hello Alex! I've noted that you're a vegetarian and have a nut allergy. I'll keep this in mind for any food-related recommendations or discussions."}- ],- "user_id": "alex",- "metadata": {- "food": "vegan"- }- }'-```--```json Output-{- "results": [- {- "memory": "Name is Alex",- "event": "ADD"- },- {- "memory": "Is a vegetarian",- "event": "ADD"- },- {- "memory": "Is allergic to nuts",- "event": "ADD"- }- ]-}-```--</CodeGroup>--<Note>- When passing `user_id`, memories are primarily created based on user messages, but may be influenced by assistant messages for contextual understanding. For example, in a conversation about food preferences, both the user's stated preferences and their responses to the assistant's questions would form user memories. Similarly, when using `agent_id`, assistant messages are prioritized, but user messages might influence the agent's memories based on context.-- **Example:**- ```- User: My favorite cuisine is Italian- Assistant: Nice! What about Indian cuisine?- User: Don't like it much since I cannot eat spicy food-- Resulting user memories:- memory1 - Likes Italian food- memory2 - Doesn't like Indian food since cannot eat spicy-- (memory2 comes from user's response about Indian cuisine)- ```-</Note>--<Note>Metadata allows you to store structured information (location, timestamp, user state) with memories. Add it during creation to enable precise filtering and retrieval during searches.</Note>--#### Short-term memory for sessions--<CodeGroup>--```python Python-messages = [- {"role": "user", "content": "I'm planning a trip to Japan next month."},- {"role": "assistant", "content": "That's exciting, Alex! A trip to Japan next month sounds wonderful. Would you like some recommendations for vegetarian-friendly restaurants in Japan?"},- {"role": "user", "content": "Yes, please! Especially in Tokyo."},- {"role": "assistant", "content": "Great! I'll remember that you're interested in vegetarian restaurants in Tokyo for your upcoming trip. I'll prepare a list for you in our next interaction."}-]--client.add(messages, user_id="alex", run_id="trip-planning-2024")-```--```javascript JavaScript-const messages = [- {"role": "user", "content": "I'm planning a trip to Japan next month."},- {"role": "assistant", "content": "That's exciting, Alex! A trip to Japan next month sounds wonderful. Would you like some recommendations for vegetarian-friendly restaurants in Japan?"},- {"role": "user", "content": "Yes, please! Especially in Tokyo."},- {"role": "assistant", "content": "Great! I'll remember that you're interested in vegetarian restaurants in Tokyo for your upcoming trip. I'll prepare a list for you in our next interaction."}-];-client.add(messages, { user_id: "alex", run_id: "trip-planning-2024" })- .then(response => console.log(response))- .catch(error => console.error(error));-```--```bash cURL-curl -X POST "https://api.mem0.ai/v1/memories/" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "messages": [- {"role": "user", "content": "I'm planning a trip to Japan next month."},- {"role": "assistant", "content": "That's exciting, Alex! A trip to Japan next month sounds wonderful. Would you like some recommendations for vegetarian-friendly restaurants in Japan?"},- {"role": "user", "content": "Yes, please! Especially in Tokyo."},- {"role": "assistant", "content": "Great! I'll remember that you're interested in vegetarian restaurants in Tokyo for your upcoming trip. I'll prepare a list for you in our next interaction."}- ],- "user_id": "alex",- "run_id": "trip-planning-2024"- }'-```--```json Output-{- "results": [- {- "memory": "Planning a trip to Japan next month",- "event": "ADD"- },- {- "memory": "Interested in vegetarian restaurants in Tokyo",- "event": "ADD"- }- ]-}-```--</CodeGroup>--#### Agent memories--<CodeGroup>--```python Python-messages = [- {"role": "system", "content": "You are an AI tutor with a personality. Give yourself a name for the user."},- {"role": "assistant", "content": "Understood. I'm an AI tutor with a personality. My name is Alice."}-]--client.add(messages, agent_id="ai-tutor")-```--```javascript JavaScript-const messages = [- {"role": "system", "content": "You are an AI tutor with a personality. Give yourself a name for the user."},- {"role": "assistant", "content": "Understood. I'm an AI tutor with a personality. My name is Alice."}-];-client.add(messages, { agent_id: "ai-tutor" })- .then(response => console.log(response))- .catch(error => console.error(error));-```--```bash cURL-curl -X POST "https://api.mem0.ai/v1/memories/" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "messages": [- {"role": "system", "content": "You are an AI tutor with a personality. Give yourself a name for the user."},- {"role": "assistant", "content": "Understood. I'm an AI tutor with a personality. My name is Alice."}- ],- "agent_id": "ai-tutor"- }'-```--</CodeGroup>--<Note>- The `agent_id` retains memories exclusively based on messages generated by the assistant or those explicitly provided as input to the assistant. Messages outside these criteria are not stored as memory.-</Note>--#### Dual user and agent memories--When you provide both `user_id` and `agent_id`, Mem0 will store memories for both identifiers separately:-- Memories from messages with `"role": "user"` are automatically tagged with the provided `user_id`-- Memories from messages with `"role": "assistant"` are automatically tagged with the provided `agent_id`-- During retrieval, you can provide either `user_id` or `agent_id` to access the respective memories-- You can continuously enrich existing memory collections by adding new memories to the same `user_id` or `agent_id` in subsequent API calls, either together or separately, allowing for progressive memory building over time-- This dual-tagging approach enables personalized experiences for both users and AI agents in your application--<CodeGroup>--```python Python-messages = [- {"role": "user", "content": "I'm travelling to San Francisco"},- {"role": "assistant", "content": "That's great! I'm going to Dubai next month."},-]--client.add(messages=messages, user_id="user1", agent_id="agent1")-```--```javascript JavaScript-const messages = [- {"role": "user", "content": "I'm travelling to San Francisco"},- {"role": "assistant", "content": "That's great! I'm going to Dubai next month."},-]--client.add(messages, { user_id: "user1", agent_id: "agent1" })- .then(response => console.log(response))- .catch(error => console.error(error));-```--```bash cURL-curl -X POST "https://api.mem0.ai/v1/memories/" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "messages": [- {"role": "user", "content": "I'm travelling to San Francisco"},- {"role": "assistant", "content": "That's great! I'm going to Dubai next month."},- ],- "user_id": "user1",- "agent_id": "agent1"- }'-```--```json Output-{- "results": [- {- // memory from user1- "id": "c57abfa2-f0ac-48af-896a-21728dbcecee0",- "data": {"memory": "Travelling to San Francisco"},- "event": "ADD"- },- {- // memory from agent1- "id": "0e8c003f-7db7-426a-9fdc-a46f9331a0c2",- "data": {"memory": "Going to Dubai next month"},- "event": "ADD"- }- ]-}-```--</CodeGroup>--## Advanced Search Operations--### Search with Custom Filters--Our advanced search allows you to set custom search filters for precise memory retrieval. You can filter by `user_id`, `agent_id`, `app_id`, `run_id`, `created_at`, `updated_at`, `categories`, and `text`. The filters support logical operators (AND, OR) and comparison operators (`in`, `gte`, `lte`, `gt`, `lt`, `ne`, `contains`, `icontains`, `*`). The wildcard character (`*`) matches everything for a specific field.--#### Filterable Fields--You can filter by the following fields:-- **Session identifiers**: `user_id`, `agent_id`, `run_id`, `app_id`-- **Timestamps**: `created_at`, `updated_at`-- **Content**: `categories`, `metadata` fields-- **Text**: Memory content (platform-specific)--#### Filter Operators--**Logical Operators:**-- `AND`: All conditions must match-- `OR`: At least one condition must match-- `NOT`: Exclude matching conditions (platform-specific)--**Comparison Operators:**-- `in`: Match any value in array (e.g., `{"agent_id": {"in": ["bot1", "bot2"]}}`)-- `gte`, `lte`: Greater/less than or equal (dates, numbers)-- `gt`, `lt`: Greater/less than (dates, numbers)-- `ne`: Not equal to-- `contains`: Partial text match (e.g., `{"categories": {"contains": "finance"}}`)-- `icontains`: Case-insensitive partial match-- `*`: Wildcard - matches any value for the field--#### Using Filters--**Method 1: Direct Parameters (Recommended for simple queries)**-```python-# Search for a specific user-client.search("query", user_id="alice")--# Search with agent context-client.search("query", user_id="alice", agent_id="travel-bot")-```--**Method 2: Filters Object (For complex queries)**+</Step>+<Step title="Create an async client">```python-# Combine multiple conditions-filters = {- "AND": [- {"user_id": "alice"},- {"agent_id": {"in": ["bot1", "bot2"]}}- ]-}-client.search("query", filters=filters)-```--#### Example 1: OR Logic - Multiple User or Agent IDs--Search memories from either a specific user OR from specific agents:--<CodeGroup>--```python Python-query = "What do you know about me?"-filters = {- "OR": [- {"user_id": "alex"},- {"agent_id": {"in": ["travel-assistant", "customer-support"]}}- ]-}-client.search(query, filters=filters)-```--```javascript JavaScript-const query = "What do you know about me?";-const filters = {- "OR":[- {- "user_id":"alex"- },- {- "agent_id":{- "in":[- "travel-assistant",- "customer-support"- ]- }- }- ]-};-client.search(query, { filters })- .then(results => console.log(results))- .catch(error => console.error(error));-```--```bash cURL-curl -X POST "https://api.mem0.ai/v2/memories/search/" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "query": "What do you know about me?",- "filters": {- "OR": [- {- "user_id": "alex"- },- {- "agent_id": {- "in": ["travel-assistant", "customer-support"]- }- }- ]- }- }'-```--</CodeGroup>--#### Example 2: Search using date filters--<CodeGroup>-```python Python-query = "What do you know about me?"-filters = {- "AND": [- {"user_id": "alex"},- {"created_at": {"gte": "2024-07-01", "lte": "2024-07-31"}}- ]-}-client.search(query, filters=filters)-```--```javascript JavaScript-const query = "What do you know about me?";-const filters = {- "AND": [- {"user_id": "alex"},- {"created_at": {"gte": "2024-07-01", "lte": "2024-07-31"}}- ]-};--client.search(query, { filters })- .then(results => console.log(results))- .catch(error => console.error(error));-```--```bash cURL-curl -X POST "https://api.mem0.ai/v2/memories/search/" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "query": "What do you know about me?",- "filters": {- "AND": [- {"user_id": "alex"},- {- "created_at": {- "gte": "2024-07-01",- "lte": "2024-07-31"- }- }- ]- }- }'-```-</CodeGroup>--#### Example 3: Search using categories filters--<CodeGroup>-```python Python-# Example 3a: Using 'contains' for partial matching-query = "What are my financial goals?"-filters = {- "AND": [- { "user_id": "alice" },- {- "categories": {- "contains": "finance"- }- }- ]-}-client.search(query, filters=filters)--# Example 3b: Using 'in' for exact matching-query = "What personal information do you have?"-filters = {- "AND": [- { "user_id": "alice" },- {- "categories": {- "in": ["personal_information"]- }- }- ]-}-client.search(query, filters=filters)-```--```javascript JavaScript-// Example 3a: Using 'contains' for partial matching-const query1 = "What are my financial goals?";-const filters1 = {- "AND": [- { "user_id": "alice" },- {- "categories": {- "contains": "finance"- }- }- ]-};--client.search(query1, { filters: filters1 })- .then(results => console.log(results))- .catch(error => console.error(error));--// Example 3b: Using 'in' for exact matching-const query2 = "What personal information do you have?";-const filters2 = {- "AND": [- { "user_id": "alice" },- {- "categories": {- "in": ["personal_information"]- }- }- ]-};--client.search(query2, { filters: filters2 })- .then(results => console.log(results))- .catch(error => console.error(error));-```--```bash cURL-# Example 3a: Using 'contains' for partial matching-curl -X POST "https://api.mem0.ai/v2/memories/search/" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "query": "What are my financial goals?",- "filters": {- "AND": [- { "user_id": "alice" },- {- "categories": {- "contains": "finance"- }- }- ]- }- }'--# Example 3b: Using 'in' for exact matching-curl -X POST "https://api.mem0.ai/v2/memories/search/" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "query": "What personal information do you have?",- "filters": {- "AND": [- { "user_id": "alice" },- {- "categories": {- "in": ["personal_information"]- }- }- ]- }- }'-```-</CodeGroup>--#### Example 4: Search using NOT filters--<CodeGroup>-```python Python-query = "What do you know about me?"-filters = {- "AND": [- {"user_id": "alex"},- {- "NOT": [- {"categories": {"contains": "food_preferences"}}- ]- }- ]-}-client.search(query, filters=filters)-```--```javascript JavaScript-const query = "What do you know about me?";-const filters = {- "AND": [- {"user_id": "alex"},- {- "NOT": [- {"categories": {"contains": "food_preferences"}}- ]- }- ]-};--client.search(query, { filters })- .then(results => console.log(results))- .catch(error => console.error(error));-```--```bash cURL-curl -X POST "https://api.mem0.ai/v2/memories/search/" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "query": "What do you know about me?",- "filters": {- "NOT": [- {- "categories": {- "contains": "food_preferences"- }- }- ]- }- }'-```-</CodeGroup>--#### Example 5: Wildcard Filters - Match Any Value--Use `*` wildcard to match memories that have any value for a specific field:--<CodeGroup>-```python Python-query = "What do you know about me?"-filters = {- "AND": [- {"user_id": "alex"},- {"run_id": "*"} # Only memories that have a run_id (any value)- ]-}-client.search(query, filters=filters)-```--```javascript JavaScript-const query = "What do you know about me?";-const filters = {- "AND": [- {- "user_id": "alex"- },- {- "run_id": "*" // Matches all run_ids- }- ]-};--client.search(query, { filters })- .then(results => console.log(results))- .catch(error => console.error(error));-```--```bash cURL-curl -X POST "https://api.mem0.ai/v2/memories/search/" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "query": "What do you know about me?",- "filters": {- "AND": [- {- "user_id": "alex"- },- {- "run_id": "*"- }- ]- }- }'-```-</CodeGroup>--### Filter Best Practices--**1. Always Scope to User or Agent**--Always include at least a `user_id`, `agent_id`, or `run_id` to scope your search:--```python-# Good: Scoped to user-client.search("query", user_id="alice")--# Better: Scoped to user and agent-client.search("query", user_id="alice", agent_id="travel-bot")+import os+from mem0 import AsyncMemoryClient-# Best: Scoped to specific session-client.search("query", user_id="alice", agent_id="travel-bot", run_id="session-123")+memory = AsyncMemoryClient(api_key=os.environ["MEM0_API_KEY"])```--**2. Use Direct Parameters for Simple Queries**--For single-condition filters, use direct parameters instead of the filters object:--```python-# Simple and clean-client.search("query", user_id="alice", agent_id="bot")--# Unnecessarily complex-client.search("query", filters={"AND": [{"user_id": "alice"}, {"agent_id": "bot"}]})+</Step>+</Steps>+ </Tab>+ <Tab title="TypeScript">+<Steps>+<Step title="Install the OSS SDK">+```bash+npm install mem0ai```--**3. Use Filters Object for Complex Logic**--Use the `filters` parameter when you need OR logic, comparison operators, or nested conditions:--```python-# Multiple agents OR specific run-filters = {- "OR": [- {"agent_id": {"in": ["bot1", "bot2"]}},- {"run_id": "special-session"}- ]-}-client.search("query", user_id="alice", filters=filters)+</Step>+<Step title="Load your API key">+```bash+export MEM0_API_KEY="sk-platform-..."```+</Step>+<Step title="Instantiate the client">+```typescript+import { Memory } from "mem0ai";-**4. Combine Direct Parameters with Filters**--You can mix direct parameters with filters for cleaner code:--```python-# User is required, plus complex date/category logic-filters = {- "AND": [- {"created_at": {"gte": "2024-07-01"}},- {"categories": {"contains": "important"}}- ]-}-client.search("query", user_id="alice", filters=filters)+const memory = new Memory({ apiKey: process.env.MEM0_API_KEY!, async: true });```+</Step>+</Steps>+ </Tab>+</Tabs>-**5. Platform vs OSS Differences**--Some features are Platform-only:-- **Categories**: Auto-generated on Platform, manual on OSS-- **Date filters**: Platform tracks timestamps automatically-- **NOT operator**: Only available on Platform-- **Wildcard (`*`)**: Behavior may vary+## Add memories with metadata and graph context+<Tabs>+ <Tab title="Python">+<Steps>+<Step title="Record conversations with metadata">```python-# This works everywhere-m.search("query", user_id="alice", agent_id="bot")--# This is Platform-only-client.search("query", filters={- "AND": [- {"user_id": "alice"},- {"categories": {"contains": "travel"}} # Platform only- ]-})-```-------## Advanced Retrieval Operations--### Get All Memories with Pagination--<Note>The `get_all` method supports two output formats: `v1.0` (default) and `v1.1`. To use the latest format, which provides more detailed information about each memory operation, set the `output_format` parameter to `v1.1`.</Note>--<Note>We're soon deprecating the default output format for the `get_all()` method, which returned a list. Once the changes are live, paginated response will be the only supported format, with 100 memories per page by default. You can customize this using the `page` and `page_size` parameters.</Note>--#### Get all memories of a user--<CodeGroup>--```python Python-memories = client.get_all(user_id="alex", page=1, page_size=50)-```--```javascript JavaScript-client.getAll({ user_id: "alex", page: 1, page_size: 50 })- .then(memories => console.log(memories))- .catch(error => console.error(error));-```--```bash cURL-curl -X GET "https://api.mem0.ai/v1/memories/?user_id=alex&page=1&page_size=50" \- -H "Authorization: Token your-api-key"-```--```json Output (v1.1)-{- "count": 204,- "next": "https://api.mem0.ai/v1/memories/?user_id=alex&output_format=v1.1&page=2&page_size=50",- "previous": null,- "results": [- {- "id":"f38b689d-6b24-45b7-bced-17fbb4d8bac7",- "memory":"Is a vegetarian and allergic to nuts.",- "agent_id":"travel-assistant",- "hash":"62bc074f56d1f909f1b4c2b639f56f6a",- "metadata":null,- "immutable": false,- "expiration_date": null,- "created_at":"2024-07-25T23:57:00.108347-07:00",- "updated_at":"2024-07-25T23:57:00.108367-07:00",- "categories":null- }- ]-}-```--</CodeGroup>--#### Get all memories by categories--You can filter memories by their categories when using get_all:--<CodeGroup>--```python Python-# Get memories with specific categories-memories = client.get_all(user_id="alex", categories=["likes"])--# Get memories with multiple categories-memories = client.get_all(user_id="alex", categories=["likes", "food_preferences"])--# Custom pagination with categories-memories = client.get_all(user_id="alex", categories=["likes"], page=1, page_size=50)--# Get memories with specific keywords-memories = client.get_all(user_id="alex", keywords="to play", page=1, page_size=50)-```--```javascript JavaScript-// Get memories with specific categories-client.getAll({ user_id: "alex", categories: ["likes"] })- .then(memories => console.log(memories))- .catch(error => console.error(error));--// Get memories with multiple categories-client.getAll({ user_id: "alex", categories: ["likes", "food_preferences"] })- .then(memories => console.log(memories))- .catch(error => console.error(error));--// Custom pagination with categories-client.getAll({ user_id: "alex", categories: ["likes"], page: 1, page_size: 50 })- .then(memories => console.log(memories))- .catch(error => console.error(error));--// Get memories with specific keywords-client.getAll({ user_id: "alex", keywords: "to play", page: 1, page_size: 50 })- .then(memories => console.log(memories))- .catch(error => console.error(error));-```--```bash cURL-# Get memories with specific categories-curl -X GET "https://api.mem0.ai/v1/memories/?user_id=alex&categories=likes" \- -H "Authorization: Token your-api-key"--# Get memories with multiple categories-curl -X GET "https://api.mem0.ai/v1/memories/?user_id=alex&categories=likes,food_preferences" \- -H "Authorization: Token your-api-key"--# Custom pagination with categories-curl -X GET "https://api.mem0.ai/v1/memories/?user_id=alex&categories=likes&page=1&page_size=50" \- -H "Authorization: Token your-api-key"--# Get memories with specific keywords-curl -X GET "https://api.mem0.ai/v1/memories/?user_id=alex&keywords=to play&page=1&page_size=50" \- -H "Authorization: Token your-api-key"-```--</CodeGroup>--#### Get all memories using custom filters--Our advanced retrieval allows you to set custom filters when fetching memories. You can filter by user_id, agent_id, app_id, run_id, created_at, updated_at, categories, and keywords. The filters support logical operators (AND, OR) and comparison operators (in, gte, lte, gt, lt, ne, contains, icontains, `*`). The wildcard character (`*`) matches everything for a specific field.--For the **categories** field specifically:-- Use `contains` for partial matching (e.g., `{"categories": {"contains": "finance"}}`)-- Use `in` for exact matching (e.g., `{"categories": {"in": ["personal_information"]}}`).--You need to define `version` as `v2` in the `get_all` method.--<CodeGroup>--```python Python-filters = {- "AND":[- {- "user_id":"alex"- },- {- "created_at":{- "gte":"2024-07-01",- "lte":"2024-07-31"- }- },- {- "categories":{- "contains": "food_preferences"- }- }- ]-}--# Default (No Pagination)-client.get_all(filters=filters)--# Pagination (You can also use the page and page_size parameters)-client.get_all(filters=filters, page=1, page_size=50)-```--```javascript JavaScript-const filters = {- "AND":[- {- "user_id":"alex"- },- {- "created_at":{- "gte":"2024-07-01",- "lte":"2024-07-31"- }- },- {- "categories":{- "contains": "food_preferences"- }- }- ]-};--// Default (No Pagination)-client.getAll({ filters })- .then(memories => console.log(memories))- .catch(error => console.error(error));--// Pagination (You can also use the page and page_size parameters)-client.getAll({ filters, page: 1, page_size: 50 })- .then(memories => console.log(memories))- .catch(error => console.error(error));-```--```bash cURL-# Default (No Pagination)-curl -X GET "https://api.mem0.ai/v2/memories/" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "filters": {- "AND": [- {"user_id":"alex"},- {"created_at":{- "gte":"2024-07-01",- "lte":"2024-07-31"- }},- {"categories":{- "contains": "food_preferences"- }}- ]- }- }'--# Pagination (You can also use the page and page_size parameters)-curl -X GET "https://api.mem0.ai/v2/memories/&page=1&page_size=50" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "filters": {- "AND": [- {"user_id":"alex"},- {"created_at":{- "gte":"2024-07-01",- "lte":"2024-07-31"- }},- {"categories":{- "contains": "food_preferences"- }}- ]- }- }'-```--</CodeGroup>--## Memory Management Operations--### Memory History--Get history of how a memory has changed over time.--<CodeGroup>--```python Python-# Add some message to create history-messages = [{"role": "user", "content": "I recently tried chicken and I loved it. I'm thinking of trying more non-vegetarian dishes.."}]-client.add(messages, user_id="alex")--# Add second message to update history-messages.append({'role': 'user', 'content': 'I turned vegetarian now.'})-client.add(messages, user_id="alex")--# Get history of how memory changed over time-memory_id = "<memory-id-here>"-history = client.history(memory_id)-```--```javascript JavaScript-// Add some message to create history-let messages = [{ role: "user", content: "I recently tried chicken and I loved it. I'm thinking of trying more non-vegetarian dishes.." }];-client.add(messages, { user_id: "alex" })- .then(result => {- // Add second message to update history- messages.push({ role: 'user', content: 'I turned vegetarian now.' });- return client.add(messages, { user_id: "alex" });- })- .then(result => {- // Get history of how memory changed over time- const memoryId = result.id; // Assuming the API returns the memory ID- return client.history(memoryId);- })- .then(history => console.log(history))- .catch(error => console.error(error));-```--```bash cURL-# First, add the initial memory-curl -X POST "https://api.mem0.ai/v1/memories/" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "messages": [{"role": "user", "content": "I recently tried chicken and I loved it. I'm thinking of trying more non-vegetarian dishes.."}],- "user_id": "alex"- }'--# Then, update the memory-curl -X POST "https://api.mem0.ai/v1/memories/" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "messages": [- {"role": "user", "content": "I recently tried chicken and I loved it. I'm thinking of trying more non-vegetarian dishes.."},- {"role": "user", "content": "I turned vegetarian now."}- ],- "user_id": "alex"- }'--# Finally, get the history (replace <memory-id-here> with the actual memory ID)-curl -X GET "https://api.mem0.ai/v1/memories/<memory-id-here>/history/" \- -H "Authorization: Token your-api-key"-```--```json Output-[- {- "id":"d6306e85-eaa6-400c-8c2f-ab994a8c4d09",- "memory_id":"b163df0e-ebc8-4098-95df-3f70a733e198",- "input":[- {- "role":"user",- "content":"I recently tried chicken and I loved it. I'm thinking of trying more non-vegetarian dishes.."- },- {- "role":"user",- "content":"I turned vegetarian now."- }- ],- "old_memory":"None",- "new_memory":"Turned vegetarian.",- "user_id":"alex",- "event":"ADD",- "metadata":"None",- "created_at":"2024-07-26T01:02:41.737310-07:00",- "updated_at":"2024-07-26T01:02:41.726073-07:00"- }+conversation = [+ {"role": "user", "content": "I'm Morgan, planning a 3-week trip to Japan in May."},+ {"role": "assistant", "content": "Great! I'll track dietary notes and cities you mention."},+ {"role": "user", "content": "Please remember I avoid shellfish and prefer boutique hotels in Tokyo."},]-```-</CodeGroup>-### Update Memory--Update a memory with new data. You can update the memory's text, metadata, or both.--<CodeGroup>--```python Python-client.update(- memory_id="<memory-id-here>",- text="I am now a vegetarian.",- metadata={"diet": "vegetarian"}+result = await memory.add(+ conversation,+ user_id="traveler-42",+ metadata={"trip": "japan-2025", "preferences": ["boutique", "no-shellfish"]},+ enable_graph=True,+ run_id="planning-call-1",)```--```javascript JavaScript-client.update("memory-id-here", { text: "I am now a vegetarian.", metadata: { diet: "vegetarian" } })- .then(result => console.log(result))- .catch(error => console.error(error));-```--```bash cURL-curl -X PUT "https://api.mem0.ai/v1/memories/<memory-id-here>" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "message": "I recently tried chicken and I loved it. I'm thinking of trying more non-vegetarian dishes.."- }'-```--```json Output-{- "id":"c190ab1a-a2f1-4f6f-914a-495e9a16b76e",- "memory":"I recently tried chicken and I loved it. I'm thinking of trying more non-vegetarian dishes..",- "agent_id":"travel-assistant",- "hash":"af1161983e03667063d1abb60e6d5c06",- "metadata":"None",- "created_at":"2024-07-30T22:46:40.455758-07:00",- "updated_at":"2024-07-30T22:48:35.257828-07:00"-}-```--</CodeGroup>--## Batch Operations--### Batch Update Memories--Update multiple memories in a single API call. You can update up to 1000 memories at once.--<CodeGroup>-```python Python-update_memories = [- {- "memory_id": "285ed74b-6e05-4043-b16b-3abd5b533496",- "text": "Watches football"- },- {- "memory_id": "2c9bd859-d1b7-4d33-a6b8-94e0147c4f07",- "text": "Loves to travel"- }-]--response = client.batch_update(update_memories)-print(response)-```--```javascript JavaScript-const updateMemories = [- {- "memory_id": "285ed74b-6e05-4043-b16b-3abd5b533496",- text: "Watches football"- },- {- "memory_id": "2c9bd859-d1b7-4d33-a6b8-94e0147c4f07",- text: "Loves to travel"- }-];--client.batchUpdate(updateMemories)- .then(response => console.log('Batch update response:', response))- .catch(error => console.error(error));-```--```bash cURL-curl -X PUT "https://api.mem0.ai/v1/memories/batch/" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "memories": [- {- "memory_id": "285ed74b-6e05-4043-b16b-3abd5b533496",- "text": "Watches football"- },- {- "memory_id": "2c9bd859-d1b7-4d33-a6b8-94e0147c4f07",- "text": "Loves to travel"- }- ]- }'-```--```json Output-{- "message": "Successfully updated 2 memories"-}-```-</CodeGroup>--### Batch Delete Memories--Delete multiple memories in a single API call. You can delete up to 1000 memories at once.--<CodeGroup>-```python Python-delete_memories = [- {"memory_id": "285ed74b-6e05-4043-b16b-3abd5b533496"},- {"memory_id": "2c9bd859-d1b7-4d33-a6b8-94e0147c4f07"}-]--response = client.batch_delete(delete_memories)-print(response)-```--```javascript JavaScript-const deleteMemories = [- {"memory_id": "285ed74b-6e05-4043-b16b-3abd5b533496"},- {"memory_id": "2c9bd859-d1b7-4d33-a6b8-94e0147c4f07"}+</Step>+</Steps>+ </Tab>+ <Tab title="TypeScript">+<Steps>+<Step title="Capture context-rich memories">+```typescript+const conversation = [+ { role: "user", content: "I'm Morgan, planning a 3-week trip to Japan in May." },+ { role: "assistant", content: "Great! I'll track dietary notes and cities you mention." },+ { role: "user", content: "Please remember I avoid shellfish and love boutique hotels in Tokyo." },];-client.batchDelete(deleteMemories)- .then(response => console.log('Batch delete response:', response))- .catch(error => console.error(error));-```--```bash cURL-curl -X DELETE "https://api.mem0.ai/v1/memories/batch/" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "memory_ids": [- {"memory_id": "285ed74b-6e05-4043-b16b-3abd5b533496"},- {"memory_id": "2c9bd859-d1b7-4d33-a6b8-94e0147c4f07"}- ]- }'-```--```json Output-{- "message": "Successfully deleted 2 memories"-}-```-</CodeGroup>--## Entity Management--### Get All Users--Get all users, agents, and runs which have memories associated with them.--<CodeGroup>--```python Python-client.users()-```--```javascript JavaScript-client.users()- .then(users => console.log(users))- .catch(error => console.error(error));-```--```bash cURL-curl -X GET "https://api.mem0.ai/v1/entities/" \- -H "Authorization: Token your-api-key"-```--```json Output-[- {- "id": "1",- "name": "user123",- "created_at": "2024-07-17T16:47:23.899900-07:00",- "updated_at": "2024-07-17T16:47:23.899918-07:00",- "total_memories": 5,- "owner": "alex",- "metadata": {"foo": "bar"},- "type": "user"- },- {- "id": "2",- "name": "travel-agent",- "created_at": "2024-07-01T17:59:08.187250-07:00",- "updated_at": "2024-07-01T17:59:08.187266-07:00",- "total_memories": 10,- "owner": "alex",- "metadata": {"agent_id": "123"},- "type": "agent"- }-]-```--</CodeGroup>--### Delete Operations--Delete specific memory:--<CodeGroup>--```python Python-client.delete(memory_id)-```--```javascript JavaScript-client.delete("memory-id-here")- .then(result => console.log(result))- .catch(error => console.error(error));-```--```bash cURL-curl -X DELETE "https://api.mem0.ai/v1/memories/memory-id-here" \- -H "Authorization: Token your-api-key"-```--</CodeGroup>--Delete all memories of a user:--<CodeGroup>--```python Python-client.delete_all(user_id="alex")-```--```javascript JavaScript-client.deleteAll({ user_id: "alex" })- .then(result => console.log(result))- .catch(error => console.error(error));-```--```bash cURL-curl -X DELETE "https://api.mem0.ai/v1/memories/?user_id=alex" \- -H "Authorization: Token your-api-key"-```--</CodeGroup>--Delete specific user or agent:--<CodeGroup>-```python Python-# Delete specific user-client.delete_users(user_id="alex")--# Delete specific agent-# client.delete_users(agent_id="travel-assistant")-```--```javascript JavaScript-client.delete_users({ user_id: "alex" })- .then(result => console.log(result))- .catch(error => console.error(error));-```--```bash cURL-curl -X DELETE "https://api.mem0.ai/v2/entities/user/alex" \- -H "Authorization: Token your-api-key"-```-</CodeGroup>--### Reset Client--<CodeGroup>--```python Python-client.reset()-```--```json Output-{'message': 'Client reset successful. All users and memories deleted.'}+const result = await memory.add(conversation, {+ userId: "traveler-42",+ metadata: { trip: "japan-2025", preferences: ["boutique", "no-shellfish"] },+ enableGraph: true,+ runId: "planning-call-1",+});```+</Step>+</Steps>+ </Tab>+</Tabs>-</CodeGroup>--### Natural Language Delete--You can also delete memories using natural language commands:+<Info icon="check">+ Successful calls return memories tagged with the metadata you passed. In the dashboard, confirm a graph edge between “Morgan” and “Tokyo” and verify the `trip=japan-2025` tag exists.+</Info>-<CodeGroup>+## Retrieve and refine-```python Python-messages = [- {"role": "user", "content": "Delete all of my food preferences"}-]-client.add(messages, user_id="alex")-```--```javascript JavaScript-const messages = [- {"role": "user", "content": "Delete all of my food preferences"}-]-client.add(messages, { user_id: "alex" })- .then(result => console.log(result))- .catch(error => console.error(error));+<Tabs>+ <Tab title="Python">+<Steps>+<Step title="Filter by metadata + reranker">+```python+matches = await memory.search(+ "Any food alerts?",+ user_id="traveler-42",+ filters={"metadata.trip": "japan-2025"},+ rerank=True,+ include_vectors=False,+)```--```bash cURL-curl -X POST "https://api.mem0.ai/v1/memories/" \- -H "Authorization: Token your-api-key" \- -H "Content-Type: application/json" \- -d '{- "messages": [{"role": "user", "content": "Delete all of my food preferences"}],- "user_id": "alex"- }'+</Step>+<Step title="Update a memory inline">+```python+await memory.update(+ memory_id=matches["results"][0]["id"],+ content="Morgan avoids shellfish and prefers boutique hotels in central Tokyo.",+)```--</CodeGroup>--## Monitor Memory Operations--You can monitor memory operations on the platform dashboard:----For more detailed information, see our [API Reference](/api-reference) or explore specific features in the [Platform Features](/platform/features/platform-overview) section.\ No newline at end of file+</Step>+</Steps>+ </Tab>+ <Tab title="TypeScript">+<Steps>+<Step title="Search with metadata filters">+```typescript+const matches = await memory.search("Any food alerts?", {+ userId: "traveler-42",+ filters: { "metadata.trip": "japan-2025" },+ rerank: true,+ includeVectors: false,+});+```+</Step>+<Step title="Apply an update">+```typescript+await memory.update(matches.results[0].id, {+ content: "Morgan avoids shellfish and prefers boutique hotels in central Tokyo.",+});+```+</Step>+</Steps>+ </Tab>+</Tabs>++<Tip>+ Need to pause graph writes on a per-request basis? Pass `enableGraph: false` (TypeScript) or `enable_graph=False` (Python) when latency matters more than relationship building.+</Tip>++## Clean up++<Tabs>+ <Tab title="Python">+<Steps>+<Step title="Delete scoped memories">+```python+await memory.delete_all(user_id="traveler-42", run_id="planning-call-1")+```+</Step>+</Steps>+ </Tab>+ <Tab title="TypeScript">+<Steps>+<Step title="Remove the run">+```typescript+await memory.deleteAll({ userId: "traveler-42", runId: "planning-call-1" });+```+</Step>+</Steps>+ </Tab>+</Tabs>++## Quick recovery++- `Missing required key enableGraph`: update the SDK to `mem0ai>=0.4.0`.+- `Graph backend unavailable`: retry with `enableGraph=False` and inspect your graph provider status.+- Empty results with filters: log `filters` values and confirm metadata keys match (case-sensitive).++<Warning>+ Metadata keys become part of your filtering schema. Stick to lowercase snake_case (`trip_id`, `preferences`) to avoid collisions down the road.+</Warning>++<CardGroup cols={2}>+ <Card+ title="Tune Metadata Filtering"+ description="Layer field-level filters on top of advanced operations."+ icon="funnel"+ href="/open-source/features/metadata-filtering"+ />+ <Card+ title="Explore Reranker Search"+ description="See how rerankers boost accuracy after vector + graph retrieval."+ icon="sparkles"+ href="/open-source/features/reranker-search"+ />+</CardGroup>diff --git a/docs/platform/features/platform-overview.mdx b/docs/platform/features/platform-overview.mdxindex cba077f9c..e17fa8bad 100644--- a/docs/platform/features/platform-overview.mdx+++ b/docs/platform/features/platform-overview.mdx@@ -1,46 +1,55 @@---+description: "See how Mem0 Platform features evolve from baseline filters to graph-powered retrieval."+icon: "sparkles"title: Overview----Learn about the key features and capabilities that make Mem0 a powerful platform for memory management and retrieval.+Mem0 Platform features help managed deployments scale from basic filtering to graph-powered retrieval and data governance. Use this page to pick the right feature lane for your team.-## Core Features+<Info>+ New to the platform? Start with the <Link href="/platform/quickstart">Platform quickstart</Link>, then dive into the journeys below.+</Info>-<CardGroup>- <Card title="Advanced Retrieval" icon="magnifying-glass" href="/platform/features/advanced-retrieval">- Superior search results using state-of-the-art algorithms, including keyword search, reranking, and filtering capabilities.- </Card>- <Card title="Contextual Add" icon="square-plus" href="/platform/features/contextual-add">- Only send your latest conversation history - we automatically retrieve the rest and generate properly contextualized memories.- </Card>- <Card title="Multimodal Support" icon="photo-film" href="/platform/features/multimodal-support">- Process and analyze various types of content including images.- </Card>- <Card title="Memory Customization" icon="filter" href="/platform/features/selective-memory">- Customize and curate stored memories to focus on relevant information while excluding unnecessary data, enabling improved accuracy, privacy control, and resource efficiency.- </Card>- <Card title="Custom Categories" icon="tags" href="/platform/features/custom-categories">- Create and manage custom categories to organize memories based on your specific needs and requirements.+## Choose your path++<CardGroup cols={3}>+ <Card title="Apply Essential Filters" icon="funnel" href="/platform/features/v2-memory-filters">+ Control which memories surface with field-level filtering and async defaults.</Card>- <Card title="Custom Instructions" icon="list-check" href="/platform/features/custom-instructions">- Define specific guidelines for your project to ensure consistent handling of information and requirements.+ <Card title="Go Real-Time with Async" icon="bolt" href="/platform/features/async-client">+ Stream add/search requests without blocking your agents.</Card>- <Card title="Direct Import" icon="message-bot" href="/platform/features/direct-import">- Tailor the behavior of your Mem0 instance with custom prompts for specific use cases or domains.+ <Card title="Unlock Graph Memory" icon="circle-nodes" href="/platform/features/graph-memory">+ Layer relationships on top of vectors for richer recalls.</Card>- <Card title="Async Client" icon="bolt" href="/platform/features/async-client">- Asynchronous client for non-blocking operations and high concurrency applications.+ <Card title="Boost Retrieval Quality" icon="sparkles" href="/platform/features/advanced-retrieval">+ Combine metadata filtering, rerankers, and per-request toggles.</Card>- <Card title="Memory Export" icon="file-export" href="/platform/features/memory-export">- Export memories in structured formats using customizable Pydantic schemas.+ <Card title="Manage Data Lifecycle" icon="database" href="/platform/features/direct-import">+ Handle imports, exports, timestamps, and expirations at scale.</Card>- <Card title="Graph Memory" icon="circle-nodes" href="/platform/features/graph-memory">- Add memories in the form of nodes and edges in a graph database and search for related memories.+ <Card title="Extend With Integrations" icon="plug" href="/platform/features/webhooks">+ Wire webhook callbacks, feedback loops, and multi-agent chat.</Card></CardGroup>-## Getting Help+<Tip>+ Self-hosting instead? Jump to the <Link href="/open-source/features/overview">OSS feature overview</Link> for equivalent capabilities.+</Tip>-If you have any questions about these features or need assistance, our team is here to help:+## Keep going-<Snippet file="get-help.mdx" />+<CardGroup cols={2}>+ <Card+ title="Compare with Open Source"+ description="See how managed features map to the OSS stack."+ icon="server"+ href="/platform/platform-vs-oss"+ />+ <Card+ title="Run the Quickstart"+ description="Provision the workspace and ship your first advanced search."+ icon="rocket"+ href="/platform/quickstart"+ />+</CardGroup>diff --git a/docs/templates/api_reference_template.mdx b/docs/templates/api_reference_template.mdxindex 5043a1f56..133d631f9 100644--- a/docs/templates/api_reference_template.mdx+++ b/docs/templates/api_reference_template.mdx@@ -124,7 +124,7 @@ const response = await fetch("https://api.mem0.ai/v1/memories", {- [Build a Customer Support Agent](/cookbooks/customer-support-agent)-<!-- DEBUG: verify CTA targets -->+{/* DEBUG: verify CTA targets */}<CardGroup cols={2}><Carddiff --git a/docs/templates/concept_guide_template.mdx b/docs/templates/concept_guide_template.mdxindex 64f00c9d3..ca6c436aa 100644--- a/docs/templates/concept_guide_template.mdx+++ b/docs/templates/concept_guide_template.mdx@@ -45,11 +45,11 @@ icon: "lightbulb"- **[Term]** – [Short definition]- **[Term]** – [Short definition]-<!-- Optional: delete if not needed -->+{/* Optional: delete if not needed */}```mermaidgraph LR- A[Input] --> B[Concept]- B --> C[Outcome]+ A[Input] */} B[Concept]+ B */} C[Outcome]```## How does it work?@@ -91,7 +91,7 @@ graph LR- [Cookbook or integration demonstrating the concept]- [Recording, demo, or sample repo]-<!-- DEBUG: verify CTA targets -->+{/* DEBUG: verify CTA targets */}<CardGroup cols={2}><Carddiff --git a/docs/templates/feature_guide_template.mdx b/docs/templates/feature_guide_template.mdxindex 6c56f8451..deff693a0 100644--- a/docs/templates/feature_guide_template.mdx+++ b/docs/templates/feature_guide_template.mdx@@ -62,12 +62,12 @@ Mem0’s advanced retrieval elevates search accuracy when basic keyword matchesAdvanced retrieval currently applies to managed Platform projects only. Self-hosted users should rely on the OSS reranker configuration.</Warning>-<!-- Optional: remove if no diagram is needed -->+{/* Optional: remove if no diagram is needed */}```mermaid%% Diagram the moving parts (delete when you fill this out)graph TD- A[Input] --> B[Feature]- B --> C[Output]+ A[Input] */} B[Feature]+ B */} C[Output]```## Feature anatomydiff --git a/docs/templates/integration_guide_template.mdx b/docs/templates/integration_guide_template.mdxindex cd01bbc32..4206c5117 100644--- a/docs/templates/integration_guide_template.mdx+++ b/docs/templates/integration_guide_template.mdx@@ -45,11 +45,11 @@ Combine Mem0’s memory layer with [Partner] to [describe the joint outcome].[Use only if access is gated or breaking changes exist. Delete when not needed.]</Warning>-<!-- Optional architecture diagram -->+{/* Optional architecture diagram */}```mermaidgraph LR- A[Mem0] --> B[Connector]- B --> C[Partner workflow]+ A[Mem0] */} B[Connector]+ B */} C[Partner workflow]```## Configure credentials@@ -170,7 +170,7 @@ partner.registerTool("recallPreferences", async (userId: string) => {- **[Issue]** — `[Fix or link to partner docs]`- **[Issue]** — `[Fix or link to Mem0 troubleshooting guide]`-<!-- DEBUG: verify CTA targets -->+{/* DEBUG: verify CTA targets */}<CardGroup cols={2}><Carddiff --git a/docs/templates/migration_guide_template.mdx b/docs/templates/migration_guide_template.mdxindex e0b066c3b..fedbfb8b8 100644--- a/docs/templates/migration_guide_template.mdx+++ b/docs/templates/migration_guide_template.mdx@@ -55,12 +55,12 @@ releaseDate: "[YYYY-MM-DD]" # Optional- [Date]: [Milestone]- [Date]: [Milestone]-<!-- Optional: delete if not needed -->+{/* Optional: delete if not needed */}```mermaidgraph LR- A[Plan] --> B[Migrate]- B --> C[Validate]- C --> D[Roll back if needed]+ A[Plan] */} B[Migrate]+ B */} C[Validate]+ C */} D[Roll back if needed]```## Plandiff --git a/docs/templates/operation_guide_template.mdx b/docs/templates/operation_guide_template.mdxindex 058996c6d..6a4e752b8 100644--- a/docs/templates/operation_guide_template.mdx+++ b/docs/templates/operation_guide_template.mdx@@ -141,7 +141,7 @@ const response = await memory.add(payload);- [Link to complementary operation]- [Link to troubleshooting playbook section]-<!-- DEBUG: verify CTA targets -->+{/* DEBUG: verify CTA targets */}<CardGroup cols={2}><Carddiff --git a/docs/templates/parameters_reference_template.mdx b/docs/templates/parameters_reference_template.mdxindex 190863645..9bb1bde05 100644--- a/docs/templates/parameters_reference_template.mdx+++ b/docs/templates/parameters_reference_template.mdx@@ -129,7 +129,7 @@ These snippets confirm the method returns the new `memory_id` for follow-up oper- **`400 Missing user_id`** — Provide either `user_id` or `agent_id` in the payload.- **`422 Metadata too large`** — Reduce metadata size below 2KB (OSS hard limit).-<!-- DEBUG: verify CTA targets -->+{/* DEBUG: verify CTA targets */}<CardGroup cols={2}><Carddiff --git a/docs/templates/quickstart_template.mdx b/docs/templates/quickstart_template.mdxindex fb31c47fd..f6d32cd03 100644--- a/docs/templates/quickstart_template.mdx+++ b/docs/templates/quickstart_template.mdx@@ -43,13 +43,13 @@ estimatedTime: "[~X minutes]"[Optional: cross-link to OSS or platform alternative if applicable. Delete if unused.]</Tip>-<!-- Optional: delete if not needed -->+{/* Optional: delete if not needed */}```mermaidgraph LR- A[Install] --> B[Configure keys]- B --> C[Add memory]- C --> D[Search]- D --> E[Delete]+ A[Install] */} B[Configure keys]+ B */} C[Add memory]+ C */} D[Search]+ D */} E[Delete]```## Install dependencies@@ -212,7 +212,7 @@ await memory.deleteAll({ userId: "alex" });- `[Error message]` → `[One-line fix or link to troubleshooting guide]`- `[Second error]` → `[How to resolve]`-<!-- DEBUG: verify CTA targets -->+{/* DEBUG: verify CTA targets */}<CardGroup cols={2}><Carddiff --git a/docs/templates/release_notes_template.mdx b/docs/templates/release_notes_template.mdxindex aa32b6dc4..465f139fb 100644--- a/docs/templates/release_notes_template.mdx+++ b/docs/templates/release_notes_template.mdx@@ -89,7 +89,7 @@ tags: ["platform", "oss"] # Optional filters- [Contributor or team] — `[Short thank-you message].`-<!-- DEBUG: verify CTA targets -->+{/* DEBUG: verify CTA targets */}<CardGroup cols={2}><Carddiff --git a/docs/templates/section_overview_template.mdx b/docs/templates/section_overview_template.mdxindex a6c493cfa..eaaa1dc83 100644--- a/docs/templates/section_overview_template.mdx+++ b/docs/templates/section_overview_template.mdx@@ -36,12 +36,12 @@ icon: "compass"Start with [Quickstart link] if you’re new, then choose a deeper topic below.</Info>-<!-- Optional: delete if not needed -->+{/* Optional: delete if not needed */}```mermaidgraph LR- A[Get set up] --> B[Learn concepts]- B --> C[Build workflows]- C --> D[Support & scale]+ A[Get set up] */} B[Learn concepts]+ B */} C[Build workflows]+ C */} D[Support & scale]```## Choose your path@@ -73,7 +73,7 @@ graph LR## Keep going-<!-- DEBUG: verify CTA targets -->+{/* DEBUG: verify CTA targets */}<CardGroup cols={2}><Carddiff --git a/docs/templates/troubleshooting_playbook_template.mdx b/docs/templates/troubleshooting_playbook_template.mdxindex c3d40534c..43824cfae 100644--- a/docs/templates/troubleshooting_playbook_template.mdx+++ b/docs/templates/troubleshooting_playbook_template.mdx@@ -96,7 +96,7 @@ Run this check:- [Feature or integration doc]- [Runbook or SLO doc]-<!-- DEBUG: verify CTA targets -->+{/* DEBUG: verify CTA targets */}<CardGroup cols={2}><Card