ExamplescriptbeginnerRunnablememory-lab
Mem0 Cloud Quickstart
Runnable example (beginner) for script using mem0, mem0ai.
Key Facts
- Level
- beginner
- Runtime
- Python • OpenAI API
- Pattern
- Memory-aware assistance with legible context
- Interaction
- Live sandbox • Script
- Updated
- 14 March 2026
Navigate this example
Library
Browse examplesReopen the wider library to compare adjacent patterns and linked learning paths.Interaction
Run sandbox nowTry the interaction directly in this example’s guided sandbox surface.Source
Open full sourceRead the real implementation, highlighted checkpoints, and runtime requirements.MCP
Call via MCPUse the same resource inside agents, deterministic exports, and MCP setup flows.
Linked principles
01-mem0-cloud-quickstart.py
python
from mem0 import MemoryClient
from dotenv import load_dotenv
import os
load_dotenv(".env")
# --------------------------------------------------------------
# Initialize Mem0 client (Cloud)
# --------------------------------------------------------------
client = MemoryClient(api_key=os.getenv("MEM0_API_KEY"))
# --------------------------------------------------------------
# Message sequence
# --------------------------------------------------------------
messages = [
{
"role": "user",
"content": "Hi, I'm Dave. I like to build AI automations!.",
},
{
"role": "assistant",
"content": "Hello Dave! I've noted that you like to build AI automations!. I'll keep this in mind for any AI automation related recommendations or discussions.",
},
]
client.add(messages, user_id="default_user")
# --------------------------------------------------------------
# Search for related memories
# --------------------------------------------------------------
query = "What shall we build today?"
# --------------------------------------------------------------
# Search for related memories
# --------------------------------------------------------------
response = client.search(query, user_id="default_user")
Related principles
- P2visibilityEnsure that background work remains perceptibleWhen the system is operating asynchronously or outside the user’s immediate focus, it should provide persistent and proportionate signals that work is continuing.Open principle →
- P3visibilityAlign feedback with the user’s level of attentionThe system should calibrate the depth and frequency of feedback according to whether the user is actively engaged, passively monitoring, or temporarily absent.Open principle →
- P7trustEstablish trust through inspectabilityUsers should be able to examine how a result was produced when confidence, accountability, or decision quality is important.Open principle →