Installation and setup
Mem0 installs from PyPI. Out of the box it calls OpenAI twice per memory, and a free Gemini key can take over both calls.
mem0ai with the LangChain packages
Three packages are needed. mem0ai is the library. The two LangChain packages are not dependencies of it; they are how this course plugs in its own model and embedder, which lesson 8 explains.
pip install "mem0ai==2.0.20" langchain langchain-corefrom importlib.metadata import version
print(version("mem0ai"))Gemini for the model and the embedderOptional
A plain Memory() uses an OpenAI chat model to extract memories and an OpenAI embedding model to index them, both on a paid key. The course replaces them with stand-ins in lessons 6 and 7, and lesson 20 goes back to a real model. Gemini's free key covers both jobs; Groq has no embedding model, so it can only replace the chat half.
pip install google-genaiexport GOOGLE_API_KEY=AIza...from mem0 import Memory
memory = Memory.from_config({
"llm": {"provider": "gemini", "config": {"model": "gemini-2.5-flash"}},
"embedder": {"provider": "gemini"},
"vector_store": {"provider": "qdrant", "config": {"embedding_model_dims": 768}},
})Gemini's embeddings have 768 numbers each and the local vector store expects 1536 unless told otherwise, which is why embedding_model_dims is set. The hosted Mem0 platform, reached with MemoryClient in lesson 21, uses MEM0_API_KEY from a Mem0 account instead.
- Run
python -c "from mem0 import Memory; Memory()"with no key set and read the error.
Little by little, you're building something great.