File size: 2,784 Bytes
0ae3f27
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
---
title: Python SDK Quickstart
description: "Install the Mem0 Python SDK, configure your environment, and store your first memory in under five minutes."
icon: "snake"
---

Get started with Mem0's Python SDK in under 5 minutes. This guide shows you how to install Mem0 and store your first memory.

## Prerequisites

- Python 3.10 or higher
- OpenAI API key ([Get one here](https://platform.openai.com/api-keys))

Set your OpenAI API key:

```bash
export OPENAI_API_KEY="your-openai-api-key"
```

<Note>
Uses OpenAI by default. Want to use Ollama, Anthropic, or local models? See [Configuration](/open-source/configuration).
</Note>

## Installation

<Steps>
<Step title="Install via pip">
```bash
pip install mem0ai
```
</Step>

<Step title="Initialize Memory">
```python
from mem0 import Memory

m = Memory()

````
</Step>

<Step title="Add a memory">
```python
messages = [
    {"role": "user", "content": "Hi, I'm Alex. I love basketball and gaming."},
    {"role": "assistant", "content": "Hey Alex! I'll remember your interests."}
]
m.add(messages, user_id="alex")
````

</Step>

<Step title="Search memories">
```python
results = m.search("What do you know about me?", user_id="alex")
print(results)
```

**Output:**

```json
{
  "results": [
    {
      "id": "mem_123abc",
      "memory": "Name is Alex. Enjoys basketball and gaming.",
      "user_id": "alex",
      "categories": ["personal_info"],
      "created_at": "2025-10-22T04:40:22.864647-07:00",
      "score": 0.89
    }
  ]
}
```

</Step>
</Steps>


<Note>
By default `Memory()` wires up:
- OpenAI `gpt-4.1-nano-2025-04-14` for fact extraction and updates
- OpenAI `text-embedding-3-small` embeddings (1536 dimensions)
- Qdrant vector store with on-disk data at `/tmp/qdrant`
- SQLite history at `~/.mem0/history.db`
- No reranker (add one in the config when you need it)
</Note>

## What's Next?

<CardGroup cols={3}>
<Card title="Memory Operations" icon="database" href="/core-concepts/memory-operations/add">
Learn how to search, update, and manage memories with full CRUD operations
</Card>

<Card title="Configuration" icon="sliders" href="/open-source/configuration">
  Customize Mem0 with different LLMs, vector stores, and embedders for production use
</Card>

<Card title="Advanced Features" icon="sparkles" href="/open-source/features/async-memory">
Explore async support, graph memory, and multi-agent memory organization
</Card>
</CardGroup>

## Additional Resources

- **[OpenAI Compatibility](/open-source/features/openai_compatibility)** - Use Mem0 with OpenAI-compatible chat completions
- **[Contributing Guide](/contributing/development)** - Learn how to contribute to Mem0
- **[Examples](/cookbooks/companions/local-companion-ollama)** - See Mem0 in action with Ollama and other integrations