1. Installation

2. API Key Setup

  1. Sign in to Mem0 Platform
  2. Copy your API Key from the dashboard

3. Instantiate Client

4. Memory Operations

Mem0 provides a simple and customizable interface for performing CRUD operations on memory.

4.1 Create Memories

Long-term memory for a user

These memory instances persist across multiple sessions. Ideal for maintaining memory over long time spans.

The add 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:

Short-term memory for a user session

These memory instances persist only for the duration of a user session. Ideal for non-repetitive interactions and managing context windows efficiently.

Please use run_id instead of session_id. The session_id parameter is deprecated and will be removed in version 0.1.20.

Long-term memory for agents

Add a memory layer for the assistants and agents so that their responses remain consistent across sessions.

Monitor Memories

You can monitor memory operations on the platform dashboard:

4.2 Search Memories

Pass user messages, interactions, and queries into our search method to retrieve relevant memories.

The search 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:

Search using custom filters

Our advanced search allows you to set custom search filters. You can filter by user_id, agent_id, app_id, date, and more.

Here you need to define version as v2 in the search method.

Example 1: Search using user_id and agent_id filters

Example 2: Search using date filters

4.3 Get All Users

Get all users, agents, and runs which have memories associated with them.

4.4 Get All Memories

Fetch all memories for a user, agent, or run using the getAll() method.

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:

Get all memories of a user

Get all memories of an AI Agent

Get the short-term memories for a session

Get specific memory

4.5 Memory History

Get history of how a memory has changed over time.

4.6 Update Memory

Update a memory with new data.

4.7 Delete Memory

Delete specific memory.

Delete all memories of a user.

Delete all users.

4.8 Reset Client

Fun fact: You can also delete the memory using the add() method by passing a natural language command:

If you have any questions, please feel free to reach out to us using one of the following methods: