Manage memories from your terminal — built for both humans and AI agents.
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.
Built for AI agents. Pass --agent (or --json) as a global flag on any command to get structured JSON output optimized for programmatic consumption — sanitized fields, no colors or spinners, and errors as JSON too. Drop it into any agent tool loop with zero extra parsing.
Run the interactive setup wizard to configure your API key:
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:
mem0 init --api-key m0-xxx --user-id alice
You can also set your API key via environment variable:
# Add a memorymem0 add "I prefer dark mode and use vim keybindings" --user-id alice# Search memoriesmem0 search "What are Alice's preferences?" --user-id alice# List all memories for a usermem0 list --user-id alice# Get a specific memorymem0 get <memory-id># Update a memorymem0 update <memory-id> "I prefer light mode now"# Delete a memorymem0 delete <memory-id>
If an existing configuration is detected, the CLI will ask for confirmation before overwriting. Use --force to skip the prompt (useful in CI/CD pipelines).
mem0 init --api-key m0-xxx --user-id alice --force
Flag
Description
--api-key
API key (skip prompt)
-u, --user-id
Default user ID (skip prompt)
--email
Login via email verification code
--code
Verification code (use with --email for non-interactive login)
Delete a single memory, all memories for a scope, or an entire entity.
# Delete a single memorymem0 delete <memory-id># Delete all memories for a usermem0 delete --all --user-id alice --force# Delete all memories project-widemem0 delete --all --project --force# Preview what would be deletedmem0 delete --all --user-id alice --dry-run
--output json returns structured data without sanitization — useful when you want the full raw API response
mem0 help --json returns the complete command tree as JSON, so agents can self-discover available commands and options
For non-interactive environments (CI, agent runtimes), set credentials via mem0 init --api-key m0-xxx --user-id alice --force or the MEM0_API_KEY environment variable.