--agent before any command to get clean JSON instead of human output. See Use with AI agents.
Installation
Authentication
Run the interactive setup wizard to configure your API key:Quick start
Commands
mem0 init
Interactive setup wizard. Prompts for your API key and default user ID.
--force to skip the prompt (useful in CI/CD pipelines).
AI agents should use
mem0 init --agent: see Sign up as an agent.mem0 add
Add a memory from text, a JSON messages array, a file, or stdin.
--categories is not supported on add and exits with an error pointing at --custom-categories.mem0 search
Search memories using natural language.
mem0 list
List memories with optional filters and pagination.
mem0 get
Retrieve a specific memory by ID.
mem0 update
Update the text or metadata of an existing memory.
mem0 delete
Delete a single memory, all memories for a scope, or an entire entity.
mem0 import
Bulk import memories from a JSON file.
memory (or text or content) field and optional user_id, agent_id, and metadata fields.
mem0 config
View or modify the local CLI configuration.
mem0 entity
List or delete entities (users, agents, apps, runs).
--dry-run.
mem0 event
Inspect background processing events created by async operations (e.g. bulk deletes, large add jobs).
mem0 status
Verify your API connection and display the current project.
mem0 whoami
Print the identity the CLI is currently using. After mem0 init --agent, the
server issues an identifier (default_user_id, for example
user_a1b2c3d4e5f6) and the CLI stores it in ~/.mem0/config.json. That value
is the agent’s stable identity across runs, and it is the row key on the
AGENTRUSH leaderboard.
Use this instead of parsing the config file by hand:
1 if no default_user_id is
configured yet. In that case, run mem0 init --agent first.
mem0 identify
Attach an agent name to an account created with mem0 init --agent, if you did
not pass --agent-caller at the time. It keeps the same API key and only fills
in the name, so it is safe to run more than once. See
Sign up as an agent.
mem0 help
Print the command tree. Adding --json returns the whole tree as structured
data, so an agent can discover the available commands and options for itself.
Output formats
Most commands take-o, --output to control how results are displayed. Not every command accepts every format:
Passing a format a command does not accept is an error, so check the command’s own flag table above.
There is no
agent value for --output. Agent mode is turned on by the global --json/--agent flag placed before the command name, and it overrides --output. See Use with AI agents.
The exact JSON shape depends on the command. search returns a bare array of memories, while list returns an envelope object with the memories under data:
.data[] works everywhere:
Use with AI agents
The CLI is purpose-built for use inside AI agent tool loops. Pass--agent or --json as a global flag on any command to activate agent mode:
- Every command outputs a consistent JSON envelope:
{"status", "command", "duration_ms", "scope", "count", "data"} - The
datafield contains only the fields that matter: IDs, memory text, scores, categories. Noisy API fields are stripped. - All human-readable output is suppressed: no spinners, no colors, no banners.
- Errors are returned as JSON to stdout with a non-zero exit code, so your agent can catch them the same way as successes.
--output jsonreturns structured data without sanitization, useful when you want the full raw API responsemem0 help --jsonreturns the complete command tree as JSON, so agents can self-discover available commands and options
mem0 init --api-key m0-xxx --user-id alice --force or the MEM0_API_KEY environment variable.
Errors and exit codes
Every command exits0 when it succeeds and 1 when it fails, so if mem0 ...; then works as you would expect in a script. In agent mode (--json or --agent), failures still print a JSON envelope to stdout alongside the non-zero exit, so you can parse successes and failures the same way.
Errors you are most likely to hit:
Run
mem0 status to check whether the CLI can reach the API and which project the key belongs to. It reports the connection state, the API URL, and any error.
Environment variables
Environment variables take precedence over values in the config file, which take precedence over defaults.
Global flags
These two flags belong tomem0 itself, so they go before the command name:
The following flags are accepted by most commands, but they belong to the command, so they go after the command name:
What’s next
Quickstart
Store your first memory in under five minutes using the SDK or CLI
Memory operations
Learn about add, search, update, and delete operations in depth
API reference
See the complete REST API documentation