> ## Documentation Index
> Fetch the complete documentation index at: https://docs.modulex.dev/llms.txt
> Use this file to discover all available pages before exploring further.

# Mem0 Integration for AI Agents & Workflows

> Persistent agent memory management — add, search, and retrieve long-term memories so AI agents can recall user context, preferences, and prior conversations across sessions.

{/* Self-hosted logo — build-time vendored from modulex.json / Iconify (see scripts/lib/logo.js). */}

<img src="https://mintcdn.com/modulexaillc/df8MOr-hXotYLTh5/logos/placeholder.svg?fit=max&auto=format&n=df8MOr-hXotYLTh5&q=85&s=a4046f9cd6d738c81259050e9833913c" alt="Mem0 logo" width="72" height="72" data-path="logos/placeholder.svg" />

## Overview

Add **Mem0** to any ModuleX agent or workflow. Persistent agent memory management against the Mem0 REST API (`api.mem0.ai`) — add, search, and retrieve long-term memories so AI agents can recall user context, preferences, and prior conversations across sessions.

<Info>
  **Categories**: AI & Machine Learning · Knowledge Base · Agentic · **Auth**: API Key · **Actions**: 3
</Info>

## Authentication

### API Key Authentication

Authenticate using your Mem0 API key

<Steps>
  <Step title="Step 1">
    Go to [https://app.mem0.ai](https://app.mem0.ai) and sign up or log in
  </Step>

  <Step title="Step 2">
    Open the dashboard and navigate to the 'API Keys' section
  </Step>

  <Step title="Step 3">
    Create a new API key or copy your existing one
  </Step>

  <Step title="Step 4">
    Paste the API key below
  </Step>
</Steps>

#### Required Credentials

| Field        | Description                        | Required | Format |
| ------------ | ---------------------------------- | -------- | ------ |
| Mem0 API Key | Your Mem0 API key from app.mem0.ai | Yes      | `-`    |

## Available Actions

<AccordionGroup>
  <Accordion title="add_memories — Add memories to Mem0 for persistent storage and retrieval.">
    ### Parameters

    <ResponseField name="user_id" type="string" required>
      User ID associated with the memory (e.g., "user\_123", "[alice@example.com](mailto:alice@example.com)")
    </ResponseField>

    <ResponseField name="messages" type="array" required>
      Array of message objects with role and content (e.g., \[\{"role": "user", "content": "Hello"}])
    </ResponseField>

    ### Response

    ```json theme={null}
    {
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        },
        "message": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Message"
        },
        "status": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Status"
        },
        "event_id": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Event Id"
        }
      },
      "required": [
        "success"
      ],
      "title": "AddMemoriesOutput",
      "type": "object"
    }
    ```
  </Accordion>

  <Accordion title="search_memories — Search for memories in Mem0 using semantic search.">
    ### Parameters

    <ResponseField name="user_id" type="string" required>
      User ID to search memories for (e.g., "user\_123", "[alice@example.com](mailto:alice@example.com)")
    </ResponseField>

    <ResponseField name="query" type="string" required>
      Search query to find relevant memories (e.g., "What are my favorite foods?")
    </ResponseField>

    <ResponseField name="limit" type="integer">
      Maximum number of results to return (e.g., 10, 50, 100) (Default: `10`)
    </ResponseField>

    ### Response

    ```json theme={null}
    {
      "$defs": {
        "SearchResultRecord": {
          "additionalProperties": false,
          "description": "A single ranked result returned by ``search_memories``.",
          "properties": {
            "id": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Id"
            },
            "memory": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Memory"
            },
            "user_id": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "User Id"
            },
            "agent_id": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Agent Id"
            },
            "app_id": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "App Id"
            },
            "run_id": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Run Id"
            },
            "hash": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Hash"
            },
            "metadata": {
              "anyOf": [
                {
                  "additionalProperties": true,
                  "type": "object"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Metadata"
            },
            "categories": {
              "items": {
                "type": "string"
              },
              "title": "Categories",
              "type": "array"
            },
            "created_at": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Created At"
            },
            "updated_at": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Updated At"
            },
            "score": {
              "anyOf": [
                {
                  "type": "number"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Score"
            }
          },
          "title": "SearchResultRecord",
          "type": "object"
        }
      },
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        },
        "search_results": {
          "items": {
            "$ref": "#/$defs/SearchResultRecord"
          },
          "title": "Search Results",
          "type": "array"
        },
        "ids": {
          "items": {
            "type": "string"
          },
          "title": "Ids",
          "type": "array"
        }
      },
      "required": [
        "success"
      ],
      "title": "SearchMemoriesOutput",
      "type": "object"
    }
    ```
  </Accordion>

  <Accordion title="get_memories — Retrieve memories from Mem0 by ID or filter criteria.">
    ### Parameters

    <ResponseField name="user_id" type="string" required>
      User ID to retrieve memories for (e.g., "user\_123", "[alice@example.com](mailto:alice@example.com)")
    </ResponseField>

    <ResponseField name="memory_id" type="string">
      Specific memory ID to retrieve (e.g., "mem\_abc123")
    </ResponseField>

    <ResponseField name="start_date" type="string">
      Start date for filtering by created\_at (e.g., "2024-01-15")
    </ResponseField>

    <ResponseField name="end_date" type="string">
      End date for filtering by created\_at (e.g., "2024-12-31")
    </ResponseField>

    <ResponseField name="limit" type="integer">
      Maximum number of results to return (e.g., 10, 50, 100) (Default: `10`)
    </ResponseField>

    <ResponseField name="page" type="integer">
      Page number to retrieve for paginated list results (Default: `1`)
    </ResponseField>

    ### Response

    ```json theme={null}
    {
      "$defs": {
        "MemoryRecord": {
          "additionalProperties": false,
          "description": "A single memory object returned by ``get_memories``.",
          "properties": {
            "id": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Id"
            },
            "memory": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Memory"
            },
            "user_id": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "User Id"
            },
            "agent_id": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Agent Id"
            },
            "app_id": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "App Id"
            },
            "run_id": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Run Id"
            },
            "hash": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Hash"
            },
            "metadata": {
              "anyOf": [
                {
                  "additionalProperties": true,
                  "type": "object"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Metadata"
            },
            "categories": {
              "items": {
                "type": "string"
              },
              "title": "Categories",
              "type": "array"
            },
            "created_at": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Created At"
            },
            "updated_at": {
              "anyOf": [
                {
                  "type": "string"
                },
                {
                  "type": "null"
                }
              ],
              "default": null,
              "title": "Updated At"
            }
          },
          "title": "MemoryRecord",
          "type": "object"
        }
      },
      "additionalProperties": false,
      "properties": {
        "success": {
          "title": "Success",
          "type": "boolean"
        },
        "error": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Error"
        },
        "memories": {
          "items": {
            "$ref": "#/$defs/MemoryRecord"
          },
          "title": "Memories",
          "type": "array"
        },
        "ids": {
          "items": {
            "type": "string"
          },
          "title": "Ids",
          "type": "array"
        },
        "count": {
          "anyOf": [
            {
              "type": "integer"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Count"
        },
        "next": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Next"
        },
        "previous": {
          "anyOf": [
            {
              "type": "string"
            },
            {
              "type": "null"
            }
          ],
          "default": null,
          "title": "Previous"
        }
      },
      "required": [
        "success"
      ],
      "title": "GetMemoriesOutput",
      "type": "object"
    }
    ```
  </Accordion>
</AccordionGroup>

## Limits & Quotas

* Rate limits and quotas depend on your Mem0 plan; see
  [https://docs.mem0.ai](https://docs.mem0.ai) for current tiers.
* `add_memories` is processed asynchronously — the response returns a
  `status` (initially `PENDING`) and an `event_id` for polling progress,
  not the stored memory records themselves.
* **Error model**: non-2xx responses and timeouts are caught and
  returned as `success=False` + `error` rather than raising. Plan for
  retries on the agent side based on the error string.

## Related integrations

<CardGroup cols={3}>
  <Card title="Airweave" href="/integrations/tools/airweave" />

  <Card title="Amazon Alexa" href="/integrations/tools/amazon-alexa" />

  <Card title="Browser Use" href="/integrations/tools/browser-use" />
</CardGroup>

## Links

* [Mem0](https://mem0.ai)
