docs/platform/quickstart.mdx
In about five minutes you will get an API key, store your first memory, and search it back. Follow along in Python, JavaScript, cURL, or the terminal.
<Note> **Are you an AI agent?** See [Sign up as an agent](/platform/agent-signup): create a working API key in four commands, with no email or dashboard. </Note>npm install mem0ai
# Nothing to install. cURL ships with macOS and most Linux distributions.
npm install -g @mem0/cli
# or, if you prefer Python: pip install mem0-cli
client = MemoryClient(api_key="your-api-key")
```javascript JavaScript
import MemoryClient from 'mem0ai';
const client = new MemoryClient({ apiKey: 'your-api-key' });
export MEM0_API_KEY="your-api-key"
mem0 init --api-key "your-api-key"
const messages = [
{"role": "user", "content": "I'm a vegetarian and allergic to nuts."},
{"role": "assistant", "content": "Got it! I'll remember your dietary preferences."}
];
await client.add(messages, { userId: "user123" });
curl -X POST https://api.mem0.ai/v3/memories/add/ \
-H "Authorization: Token $MEM0_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"messages": [
{"role": "user", "content": "Im a vegetarian and allergic to nuts."},
{"role": "assistant", "content": "Got it! Ill remember your dietary preferences."}
],
"user_id": "user123"
}'
mem0 add "I'm a vegetarian and allergic to nuts." --user-id user123
Mem0 pulls the individual facts out of the conversation and stores each one separately:
{
"results": [
{"id": "0f2c1b6e-9a3d-4b18-8f77-1c2d3e4f5a6b", "memory": "Is a vegetarian", "event": "ADD"},
{"id": "14e1b28a-2014-40ad-ac42-69c9ef42193d", "memory": "Allergic to nuts", "event": "ADD"}
]
}
const results = await client.search("What are my dietary restrictions?", { filters: { user_id: "user123" } });
console.log(results);
curl -X POST https://api.mem0.ai/v3/memories/search/ \
-H "Authorization: Token $MEM0_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"query": "What are my dietary restrictions?",
"filters": {"user_id": "user123"}
}'
mem0 search "What are my dietary restrictions?" --user-id user123
Both facts come back, ranked by how well they match the question:
{
"results": [
{
"id": "14e1b28a-2014-40ad-ac42-69c9ef42193d",
"memory": "Allergic to nuts",
"user_id": "user123",
"agent_id": null,
"app_id": null,
"run_id": null,
"categories": ["health"],
"metadata": {},
"created_at": "2025-10-22T04:40:22.864647-07:00",
"updated_at": "2025-10-22T04:40:22.864647-07:00",
"expiration_date": null,
"score": 0.87
},
{
"id": "0f2c1b6e-9a3d-4b18-8f77-1c2d3e4f5a6b",
"memory": "Is a vegetarian",
"user_id": "user123",
"agent_id": null,
"app_id": null,
"run_id": null,
"categories": ["food_preferences"],
"metadata": {},
"created_at": "2025-10-22T04:40:22.864647-07:00",
"updated_at": "2025-10-22T04:40:22.864647-07:00",
"expiration_date": null,
"score": 0.81
}
]
}
Pass these memories to your model as context, and it answers with what it already knows about the user instead of asking again.
</Step> </Steps> <Tip> Rather than calling `add` and `search` yourself, you can hand Mem0 to your agent as a set of tools and let it decide when to save and look things up. See [Mem0 MCP](/platform/mem0-mcp). </Tip>You stored and searched your first memory. Start with scoping, since every call you make from here needs it:
<CardGroup cols={2}> <Card title="Scope memories to users and agents" icon="users" href="/platform/features/entity-scoped-memory"> What `user_id` actually does, plus the `agent_id`, `app_id`, and `run_id` fields that came back empty above. </Card> <Card title="How Mem0 works" icon="diagram-project" href="/core-concepts/how-it-works"> Why one sentence became two memories, and how Mem0 decides what to keep. </Card> <Card title="Update and delete memories" icon="database" href="/core-concepts/memory-operations/add"> The operations beyond add and search, for when stored facts change or go stale. </Card> <Card title="Use Mem0 with your agent framework" icon="plug" href="/integrations"> Wire memory into LangChain, CrewAI, LangGraph, or the OpenAI Agents SDK. </Card> </CardGroup> <Note> Something not working? The [FAQs and troubleshooting](/platform/faqs) page covers the common setup errors. </Note>