Installation and setup
Installation and setup is the one-time step that installs LangMem 0.0.30 with LangChain's Groq and Google integrations and gives it two free API keys: one for the chat model and one for embeddings.
Last updated: 30 Sep, 2026 · LangMem 0.0.30
LangMem does not call a model provider itself. It hands the work to a LangChain chat model, and the store it writes to can embed text with a LangChain embedding model. So the install is LangMem plus one integration package per provider.
Installing LangMem and the integrations
langmem brings LangGraph and LangChain with it. langchain-groq is the chat model, langchain-google-genai the embeddings, and numpy speeds up the store's vector search (without it the store prints a warning and falls back to plain Python).
pip install "langmem==0.0.30" "langchain-groq==1.1.3" "langchain-google-genai==4.4.0" numpyfrom importlib.metadata import version
for package in ["langmem", "langgraph", "langchain", "langchain-groq", "langchain-google-genai"]:
print(f"{package:24} {version(package)}")langmem 0.0.30 langgraph 1.2.12 langchain 1.4.3 langchain-groq 1.1.3 langchain-google-genai 4.4.0
The version is pinned because LangMem 0.0.x may change its API between releases; LangGraph and LangChain came in as its dependencies, at the versions shown.
Getting the two free keys
| Provider | Used for | Where to get the key | Environment variable |
|---|---|---|---|
| Groq | The chat model, openai/gpt-oss-120b | console.groq.com/keys | GROQ_API_KEY |
| Google AI Studio | Embeddings, gemini-embedding-2, from the semantic search lesson on | aistudio.google.com/apikey | GOOGLE_API_KEY |
Both are free plans with daily limits. Set the keys in the shell you run Python from, or in Colab's Secrets panel:
export GROQ_API_KEY="gsk_..."
export GOOGLE_API_KEY="AIza..."Checking the chat model
init_chat_model turns a "provider:model" string into a chat model object. Every lesson starts with this line; temperature=0 makes the model pick its most likely answer, which keeps runs closer to each other.
from langchain.chat_models import init_chat_model
model = init_chat_model("groq:openai/gpt-oss-120b", temperature=0)from langchain.chat_models import init_chat_model
model = init_chat_model("groq:openai/gpt-oss-120b", temperature=0)
reply = model.invoke("Reply with one word: ready")
print(reply.text)ready
Checking the embedding model
init_embeddings does the same for embedding models. gemini-embedding-2 turns any text into a list of 3072 numbers; the store uses those to search by meaning.
from langchain.embeddings import init_embeddings
embeddings = init_embeddings("google_genai:gemini-embedding-2")
vector = embeddings.embed_query("Order A-1001 arrived broken")
print(len(vector))3072
gpt-oss-120b vs gpt-oss-20b
| openai/gpt-oss-120b | openai/gpt-oss-20b | |
|---|---|---|
| Used in this course | Every run | Only if you hit the 120b daily limit |
| Daily token budget on a free key | Its own | Its own, separate from 120b |
| Size | 120 billion parameters | 20 billion parameters |
When you come back to this setup
- Every lesson's code starts with the same imports and the
model = ...line; they only work once the keys are set in that shell or notebook. - When Groq answers
429withtokens per dayin the message, change the model string togroq:openai/gpt-oss-20bfor the rest of the day. - A new Colab session forgets environment variables; run the Secrets cell again.
Related
- Previous: LangMem overview
- Next: Extracting memories
- Reference: langmem on PyPI
- Run
pip show langmemand read which packages it requires. - Change the model string to
groq:openai/gpt-oss-20band run the chat check again. - Unset
GROQ_API_KEYand run the chat check to see the error you get without a key.
Little by little, you're building something great.