> ## Documentation Index
> Fetch the complete documentation index at: https://agno-v2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# Mem0

> Mem0Tools provides intelligent memory management capabilities for agents using the Mem0 memory platform.

## Prerequisites

You need to install the `mem0ai` and `openai` libraries.

```shell theme={null}
uv pip install mem0ai openai
```

Set `MEM0_API_KEY` to use the Mem0 Platform. The example Agent uses Agno's default OpenAI model, so it also requires `OPENAI_API_KEY`. Get the Mem0 key from the [Mem0 dashboard](https://app.mem0.ai/dashboard/api-keys).

```bash Mac/Linux theme={null}
export MEM0_API_KEY="your_mem0_api_key_here"
export OPENAI_API_KEY="your_openai_api_key_here"
```

```bash Windows theme={null}
$Env:MEM0_API_KEY="your_mem0_api_key_here"
$Env:OPENAI_API_KEY="your_openai_api_key_here"
```

Without a Mem0 API key, the toolkit runs a local Mem0 `Memory` instance. Configure it with the `config` parameter.

## Example

The following agent can store and retrieve memories using Mem0:

```python theme={null}
from agno.agent import Agent
from agno.tools.mem0 import Mem0Tools

agent = Agent(
    instructions=[
        "You are a memory-enhanced assistant that can remember information across conversations",
        "Store important information about users and their preferences",
        "Retrieve relevant memories to provide personalized responses",
        "Manage memory effectively to improve user experience",
    ],
    tools=[Mem0Tools(user_id="user_123")],
)

agent.print_response("Remember that I prefer vegetarian meals and I'm allergic to nuts", stream=True)
```

## Toolkit Params

| Parameter | Type | Default | Description |
| - | - | - | - |
| `config` | `Optional[Dict]` | `None` | Mem0 configuration dictionary. |
| `api_key` | `Optional[str]` | `None` | Mem0 API key. Uses MEM0\_API\_KEY if not set. |
| `user_id` | `Optional[str]` | `None` | User ID for memory operations. |
| `org_id` | `Optional[str]` | `None` | Organization ID. Uses MEM0\_ORG\_ID if not set. |
| `project_id` | `Optional[str]` | `None` | Project ID. Uses MEM0\_PROJECT\_ID if not set. |
| `infer` | `bool` | `True` | Enable automatic memory inference. |
| `enable_add_memory` | `bool` | `True` | Enable memory addition functionality. |
| `enable_search_memory` | `bool` | `True` | Enable memory search functionality. |
| `enable_get_all_memories` | `bool` | `True` | Enable retrieving all memories functionality. |
| `enable_delete_all_memories` | `bool` | `True` | Enable memory deletion functionality. |
| `all` | `bool` | `False` | Enable all tools. Overrides individual enable flags when `True`. |

## Toolkit Functions

| Function | Description |
| - | - |
| `add_memory` | Store new memories or information. |
| `search_memory` | Search through stored memories using queries. |
| `get_all_memories` | Retrieve all stored memories for the user. |
| `delete_all_memories` | Delete all stored memories for the user. |

## Developer Resources

* [Tools Source](https://github.com/agno-agi/agno/blob/main/libs/agno/agno/tools/mem0.py)
* [Mem0 Documentation](https://docs.mem0.ai/)
* [Mem0 Platform](https://mem0.ai/)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.