| |
| title: CLI |
| description: "Manage memories from your terminal — built for both humans and AI agents." |
| icon: "terminal" |
| iconType: "solid" |
| |
|
|
| The mem0 CLI lets you add, search, list, update, and delete memories directly from the terminal. It works with the Mem0 Platform API and is available as both an npm package and a Python package. |
|
|
| Both implementations provide identical behavior — same commands, same options, same output formats. |
|
|
| <Tip> |
| **Built for AI agents.** Pass ` |
| </Tip> |
|
|
| |
|
|
| <CodeGroup> |
| ```bash npm |
| npm install -g @mem0/cli |
| ``` |
|
|
| ```bash pip |
| pip install mem0-cli |
| ``` |
| </CodeGroup> |
|
|
| |
|
|
| Run the interactive setup wizard to configure your API key: |
|
|
| ```bash |
| mem0 init |
| ``` |
|
|
| This prompts for your API key and a default user ID, validates the connection, and saves the configuration locally. |
|
|
| For CI/CD or non-interactive environments, pass both values as flags: |
|
|
| ```bash |
| mem0 init |
| ``` |
|
|
| You can also set your API key via environment variable: |
|
|
| ```bash |
| export MEM0_API_KEY="m0-xxx" |
| ``` |
|
|
| |
|
|
| ```bash |
| |
| mem0 add "I prefer dark mode and use vim keybindings" |
|
|
| |
| mem0 search "What are Alice's preferences?" |
|
|
| |
| mem0 list |
|
|
| |
| mem0 get <memory-id> |
|
|
| |
| mem0 update <memory-id> "I prefer light mode now" |
|
|
| |
| mem0 delete <memory-id> |
| ``` |
|
|
| |
|
|
| |
|
|
| Interactive setup wizard. Prompts for your API key and default user ID. |
|
|
| ```bash |
| mem0 init |
| mem0 init |
| mem0 init |
| ``` |
|
|
| If an existing configuration is detected, the CLI will ask for confirmation before overwriting. Use ` |
|
|
| ```bash |
| mem0 init |
| ``` |
|
|
| | Flag | Description | |
| | |
| | ` |
| | `-u, |
| | ` |
| | ` |
| | ` |
|
|
| |
|
|
| Add a memory from text, a JSON messages array, a file, or stdin. |
|
|
| ```bash |
| mem0 add "I prefer dark mode" |
| mem0 add |
| echo "Loves hiking on weekends" | mem0 add |
| ``` |
|
|
| | Flag | Description | |
| | |
| | `-u, |
| | ` |
| | ` |
| | `-f, |
| | `-m, |
| | ` |
| | ` |
| | `-o, |
|
|
| |
|
|
| Search memories using natural language. |
|
|
| ```bash |
| mem0 search "dietary restrictions" |
| mem0 search "preferred tools" |
| ``` |
|
|
| | Flag | Description | |
| | |
| | `-u, |
| | `-k, |
| | ` |
| | ` |
| | ` |
| | ` |
| | ` |
| | `-o, |
|
|
| |
|
|
| List memories with optional filters and pagination. |
|
|
| ```bash |
| mem0 list |
| mem0 list |
| mem0 list |
| ``` |
|
|
| | Flag | Description | |
| | |
| | `-u, |
| | ` |
| | ` |
| | ` |
| | ` |
| | ` |
| | `-o, |
|
|
| |
|
|
| Retrieve a specific memory by ID. |
|
|
| ```bash |
| mem0 get 7b3c1a2e-4d5f-6789-abcd-ef0123456789 |
| mem0 get 7b3c1a2e-4d5f-6789-abcd-ef0123456789 |
| ``` |
|
|
| |
|
|
| Update the text or metadata of an existing memory. |
|
|
| ```bash |
| mem0 update <memory-id> "Updated preference text" |
| mem0 update <memory-id> |
| echo "new text" | mem0 update <memory-id> |
| ``` |
|
|
| |
|
|
| Delete a single memory, all memories for a scope, or an entire entity. |
|
|
| ```bash |
| |
| mem0 delete <memory-id> |
|
|
| |
| mem0 delete |
|
|
| |
| mem0 delete |
|
|
| |
| mem0 delete |
| ``` |
|
|
| | Flag | Description | |
| | |
| | ` |
| | ` |
| | ` |
| | ` |
| | ` |
|
|
| |
|
|
| Bulk import memories from a JSON file. |
|
|
| ```bash |
| mem0 import data.json |
| ``` |
|
|
| The file should be a JSON array where each item has a `memory` (or `text` or `content`) field and optional `user_id`, `agent_id`, and `metadata` fields. |
|
|
| |
|
|
| View or modify the local CLI configuration. |
|
|
| ```bash |
| mem0 config show |
| mem0 config get api_key |
| mem0 config set user_id bob |
| ``` |
|
|
| |
|
|
| List or delete entities (users, agents, apps, runs). |
|
|
| ```bash |
| mem0 entity list users |
| mem0 entity list agents |
| mem0 entity delete |
| ``` |
|
|
| |
|
|
| Inspect background processing events created by async operations (e.g. bulk deletes, large add jobs). |
|
|
| ```bash |
| |
| mem0 event list |
|
|
| |
| mem0 event status <event-id> |
| ``` |
|
|
| | Flag | Description | |
| | |
| | `-o, |
|
|
| |
|
|
| Verify your API connection and display the current project. |
|
|
| ```bash |
| mem0 status |
| ``` |
|
|
| |
|
|
| Print the CLI version. |
|
|
| ```bash |
| mem0 version |
| ``` |
|
|
| |
|
|
| All commands support the ` |
|
|
| | Format | Description | |
| | |
| | `text` | Human-readable output with colors and formatting (default for most commands) | |
| | `json` | Structured JSON, suitable for piping to `jq` or consumption by AI agents | |
| | `table` | Tabular format (default for `list`) | |
| | `quiet` | Minimal output — just IDs or status codes | |
| | `agent` | Structured JSON envelope with sanitized fields — set automatically by ` |
|
|
| Example with JSON output: |
|
|
| ```bash |
| mem0 search "user preferences" |
| ``` |
|
|
| |
|
|
| The CLI is purpose-built for use inside AI agent tool loops. Pass ` |
|
|
| - Every command outputs a consistent JSON envelope: `{"status", "command", "duration_ms", "scope", "count", "data"}` |
| - The `data` field 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. |
|
|
| ```bash |
| |
| mem0 |
| mem0 |
| mem0 |
| mem0 |
| ``` |
|
|
| <CodeGroup> |
| ```json Output: mem0 |
| { |
| "status": "success", |
| "command": "search", |
| "duration_ms": 134, |
| "scope": { "user_id": "alice" }, |
| "count": 2, |
| "data": [ |
| { "id": "abc-123", "memory": "User prefers dark mode", "score": 0.97, "created_at": "2026-01-15", "categories": ["preferences"] }, |
| { "id": "def-456", "memory": "User uses vim keybindings", "score": 0.81, "created_at": "2026-01-10", "categories": ["tools"] } |
| ] |
| } |
| ``` |
|
|
| ```json Output: mem0 |
| { |
| "status": "success", |
| "command": "add", |
| "duration_ms": 210, |
| "data": [ |
| { "id": "ghi-789", "memory": "Likes concise answers", "event": "ADD" } |
| ] |
| } |
| ``` |
| </CodeGroup> |
|
|
| Two other agent-friendly features: |
|
|
| - **` |
| - **`mem0 help |
|
|
| For non-interactive environments (CI, agent runtimes), set credentials via `mem0 init |
|
|
| |
|
|
| | Variable | Description | |
| | |
| | `MEM0_API_KEY` | API key (overrides config file) | |
| | `MEM0_BASE_URL` | API base URL | |
| | `MEM0_USER_ID` | Default user ID | |
| | `MEM0_AGENT_ID` | Default agent ID | |
| | `MEM0_APP_ID` | Default app ID | |
| | `MEM0_RUN_ID` | Default run ID | |
| | `MEM0_ENABLE_GRAPH` | Enable graph memory (`true` / `false`) | |
|
|
| Environment variables take precedence over values in the config file, which take precedence over defaults. |
|
|
| |
|
|
| These flags are available on all commands: |
|
|
| | Flag | Description | |
| | |
| | ` |
| | ` |
| | ` |
| | ` |
| | `-o, |
|
|
| |
|
|
| <CardGroup cols={3}> |
| <Card title="Quickstart" icon="bolt" href="/platform/quickstart"> |
| Store your first memory in under five minutes using the SDK or CLI |
| </Card> |
|
|
| <Card title="Memory Operations" icon="database" href="/core-concepts/memory-operations/add"> |
| Learn about add, search, update, and delete operations in depth |
| </Card> |
|
|
| <Card title="API Reference" icon="code" href="/api-reference/memory/add-memories"> |
| See the complete REST API documentation |
| </Card> |
| </CardGroup> |
|
|