1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
18 small wins to finish your pathNext lesson →
Installation and setup
LangMem installs with pip and works with any LangChain chat model. The course uses a rule-based model, and a free Groq or Gemini key covers a real one.
pip install langmem 0.0.30
LangMem brings LangGraph and LangChain's core with it. The version is pinned because LangMem is an early release whose API may still change.
pip install "langmem==0.0.30"from importlib.metadata import version
print(version("langmem"))A LangChain chat modelOptional
The course uses MemoryModel, a rule-based chat model you read in lesson 4, so no key is needed. Lesson 5 shows the change to a hosted model loaded with init_chat_model, which needs the provider's LangChain package and key.
from langchain.chat_models import init_chat_model
model = init_chat_model("google_genai:gemini-2.5-flash")| Provider | Key | Variable | Package and model string |
|---|---|---|---|
| Groq | Free, console.groq.com/keys | GROQ_API_KEY | langchain-groq, "groq:openai/gpt-oss-120b" |
| Gemini | Free, aistudio.google.com/apikey | GOOGLE_API_KEY | langchain-google-genai, "google_genai:gemini-2.5-flash" |
| OpenRouter | Free models end in :free, openrouter.ai/keys | OPENROUTER_API_KEY | langchain-openrouter, "openrouter:google/gemma-4-31b-it:free" |
| OpenAI | Paid, platform.openai.com/api-keys | OPENAI_API_KEY | langchain-openai, "openai:gpt-4o-mini" |
pip install langchain-google-genaiexport GOOGLE_API_KEY=AIza...Try it yourself
- Run
pip show langmemand read which LangGraph version it requires.
Little by little, you're building something great.