---
title: 🚀 Quickstart
description: 'Get started with Mem0 quickly!'
---

> Welcome to the Mem0 quickstart guide. This guide will help you get up and running with Mem0 in no time.

## Installation

To install Mem0, you can use pip. Run the following command in your terminal:

```bash
pip install mem0ai
```

## Basic Usage

### Initialize Mem0

<Tabs>
  <Tab title="Basic">
```python
from mem0 import Memory
m = Memory()
```
  </Tab>
  <Tab title="Advanced">
If you want to run Mem0 in production, initialize using the following method:

Run Qdrant first:

```bash
docker pull qdrant/qdrant

docker run -p 6333:6333 -p 6334:6334 \
    -v $(pwd)/qdrant_storage:/qdrant/storage:z \
    qdrant/qdrant
```

Then, instantiate memory with qdrant server:

```python
from mem0 import Memory

config = {
    "vector_store": {
        "provider": "qdrant",
        "config": {
            "host": "localhost",
            "port": 6333,
        }
    },
}

m = Memory.from_config(config)
```
  </Tab>
</Tabs>


### Store a Memory

```python
# For a user
result = m.add("Likes to play cricket on weekends", user_id="alice", metadata={"category": "hobbies"})
print(result)
```

Output:
```python
{'message': 'ok'}
```

### Retrieve Memories

```python
# Get all memories
all_memories = m.get_all()
print(all_memories)
```

Output:

```python
[
   {
      "id":"13efe83b-a8df-4ec0-814e-428d6e8451eb",
      "memory":"Likes to play cricket on weekends",
      "hash":"87bcddeb-fe45-4353-bc22-15a841c50308",
      "metadata":"None",
      "created_at":"2024-07-26T08:44:41.039788-07:00",
      "updated_at":"None",
      "user_id":"alice"
   }
]
```

```python
# Get a single memory by ID
specific_memory = m.get("m1")
print(specific_memory)
```

Output:
```python
{
      "id":"13efe83b-a8df-4ec0-814e-428d6e8451eb",
      "memory":"Likes to play cricket on weekends",
      "hash":"87bcddeb-fe45-4353-bc22-15a841c50308",
      "metadata":"None",
      "created_at":"2024-07-26T08:44:41.039788-07:00",
      "updated_at":"None",
      "user_id":"alice"
}
```

### Search Memories

```python
related_memories = m.search(query="What are Alice's hobbies?", user_id="alice")
print(related_memories)
```

Output:

```python
[
   {
      "id":"ea925981-272f-40dd-b576-be64e4871429",
      "memory":"Likes to play cricket and plays cricket on weekends.",
      "hash":"c8809002-25c1-4c97-a3a2-227ce9c20c53",
      "metadata":{
         "category":"hobbies"
      },
      "score":0.32116443111457704,
      "created_at":"2024-07-26T10:29:36.630547-07:00",
      "updated_at":"None",
      "user_id":"alice"
   }
]
```

### Update a Memory

```python
result = m.update(memory_id="m1", data="Likes to play tennis on weekends")
print(result)
```

Output:

```python
{'message': 'Memory updated successfully!'}
```

### Memory History

```python
history = m.history(memory_id="m1")
print(history)
```
Output:
```python
[
   {
      "id":"4e0e63d6-a9c6-43c0-b11c-a1bad3fc7abb",
      "memory_id":"ea925981-272f-40dd-b576-be64e4871429",
      "old_memory":"None",
      "new_memory":"Likes to play cricket and plays cricket on weekends.",
      "event":"ADD",
      "created_at":"2024-07-26T10:29:36.630547-07:00",
      "updated_at":"None"
   },
   {
      "id":"548b75f0-f442-44b9-9ca1-772a105abb12",
      "memory_id":"ea925981-272f-40dd-b576-be64e4871429",
      "old_memory":"Likes to play cricket and plays cricket on weekends.",
      "new_memory":"Likes to play tennis on weekends",
      "event":"UPDATE",
      "created_at":"2024-07-26T10:29:36.630547-07:00",
      "updated_at":"2024-07-26T10:32:46.332336-07:00"
   }
]
```

### Delete Memory

```python
m.delete(memory_id="m1") # Delete a memory

m.delete_all(user_id="alice") # Delete all memories
```

### Reset Memory

```python
m.reset() # Reset all memories
```


If you have any questions, please feel free to reach out to us using one of the following methods:

<Snippet file="get-help.mdx" />