Python SDK Quickstart - Mem0
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
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)
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
- Install via pip
pip install mem0ai
- Initialize Memory
from mem0 import Memory
m = Memory()
- 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")
- Search memories
results = m.search("What do you know about me?", filters={"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-5-minifor fact extraction and updates - OpenAI
text-embedding-3-smallembeddings (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 \ \ Search, update, and manage memories with the full CRUD API.
Configure for production \ \ Swap in your own LLM, embedder, and vector store.
Add to your framework \ \ Wire Mem0 into LangChain, CrewAI, LangGraph, and 20+ more.
If you have any questions, please feel free to reach out: