Skip to content

Skip to main content

Mem0 home pagelight logodark logo

Search...

Ctrl KAsk AI

Search...

Navigation

Getting Started

Python SDK Quickstart

Welcome Mem0 Platform Open Source Cookbooks Integrations API Reference Release Notes

Getting Started
Self-Hosting Features
Configuration
Community & Support

On this page

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

Set your OpenAI API key:

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

Uses OpenAI by default. Want to use Ollama, Anthropic, or local models? See Configuration.

Installation

1

Navigate to header

Install via pip

pip install mem0ai

2

Navigate to header

Initialize Memory

from mem0 import Memory

m = Memory()

3

Navigate to header

Add a memory

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")

4

Navigate to header

Search memories

results = m.search("What do you know about me?", user_id="alex")
print(results)

Output:

{
  "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\
    }\
  ]
}

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)

What’s Next?

Memory Operations \ \ Learn how to search, update, and manage memories with full CRUD operations

Configuration \ \ Customize Mem0 with different LLMs, vector stores, and embedders for production use

Advanced Features \ \ Explore async support, graph memory, and multi-agent memory organization

Additional Resources

Was this page helpful?

YesNo

Suggest edits Raise issue

Vibecoding with Mem0\ \ Previous Node SDK Quickstart\ \ Next

Ctrl+I

Assistant

Responses are generated using AI and may contain mistakes.

Suggestions

How do I search memories?How do I install Mem0?How do I add a memory?

Contact support

SOP Documentation Site for Mem0