---
title: Mem0
icon: /images/mem0.svg
description: Set up the Mem0 Memory resource in Python.
---

## Dependencies

The Mem0 resource needs the `mem0` extra, which installs the `mem0ai` SDK:

```bash
uv add "mirage-ai[mem0]"
```

For credential setup, see the [Mem0 Setup](/home/setup/mem0) guide.

## Configuration

```python
import os

from mirage import MountMode, Workspace
from mirage.resource.mem0 import Mem0Config, Mem0Resource

config = Mem0Config(
    api_key=os.environ["MEM0_API_KEY"],
    user_id=os.environ.get("MEM0_USER_ID"),
)
resource = Mem0Resource(config=config)
ws = Workspace({"/memory/": resource}, mode=MountMode.READ)
```

Set exactly one of `user_id`, `agent_id`, or `run_id`. Providing zero or more
than one raises a validation error.

## Config Reference

| Field                 | Required | Default                  | Description |
| --------------------- | -------- | ------------------------ | ----------- |
| `api_key`             | Yes      |                          | Mem0 API key (`m0-...`) |
| `host`                | No       | `https://api.mem0.ai`    | Mem0 API base URL |
| `user_id`             | One of   |                          | Scope the mount to a user's memories |
| `agent_id`            | One of   |                          | Scope the mount to an agent's memories |
| `run_id`              | One of   |                          | Scope the mount to a run/session's memories |
| `default_page_size`   | No       | `100`                    | Page size used when listing memories |
| `default_search_limit`| No       | `10`                     | Default `top-k` for `search` |
