store_memory
Save AI agent memory by storing content with optional metadata, session context, and LLM-based deduplication for persistent knowledge.
Instructions
Store memory content with metadata support.
REQUIRED: Either 'user_id' OR 'agent_id' (if neither provided, auto-detects current user) REQUIRED: 'content' - the information to remember
OPTIONAL: 'metadata' - structured data about the memory (JSON object) OPTIONAL: 'infer' - if True (default), uses LLM to extract facts and dedupe. Set False for faster raw storage. OPTIONAL: 'run_id' - session/run identifier for temporary context OPTIONAL: 'custom_instructions' - per-call instructions to control what gets stored OPTIONAL: 'verbose' - if True, return full details. If False (default), return compact response.
Examples:
Store personal info: {"content": "User prefers React over Vue", "user_id": "john"}
Store with metadata: {"content": "API endpoint changed", "metadata": {"type": "technical", "priority": "high"}}
Fast storage (no LLM): {"content": "Quick note", "infer": false}
Session-scoped: {"content": "Current task context", "run_id": "session_123"}
Use for: Storing code patterns, user preferences, project details, technical knowledge.
Note: With infer=True (default), mem0 uses an LLM to extract key facts and intelligently update existing memories. This is slower (~5-15s) but smarter. Use infer=False for faster raw storage (~1-2s) without deduplication.
Config: Set MEM0_INFER_DEFAULT=false in env to disable infer by default. Config: Set MEM0_VERBOSE=true in env to enable verbose responses by default.
Returns: Success message with memory ID (compact) or full details (verbose).
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| infer | No | ||
| run_id | No | ||
| content | Yes | ||
| user_id | No | ||
| verbose | No | ||
| agent_id | No | ||
| metadata | No | ||
| custom_instructions | No |
Output Schema
| Name | Required | Description | Default |
|---|---|---|---|
| result | Yes |