LangMemLangMem 0.0.30 · LangGraph 1.2 · Python 3.10+
Dashboard
0%
1
Curious builder0 XP earned · 300 to level 2
0 daysFinish a lesson to begin
Badge collection0 of 6 unlocked
19 small wins to finish your pathNext lesson →

Chat models

A chat model is the part of LangMem that does the reading: any LangChain chat model, passed as an object or as a "provider:model" string, that answers LangMem's request with tool calls.

Last updated: 30 Sep, 2026 · LangMem 0.0.30

LangMem has no model of its own. Every manager, optimizer and summarizer takes a model argument, and what it can do depends on that model: how well it follows instructions and how it makes tool calls.

Syntax:

python
create_memory_manager("groq:openai/gpt-oss-120b")  # a string: LangMem calls init_chat_model for you
create_memory_manager(model)                     # an object you configured yourself

A model string

A string is passed to LangChain's init_chat_model with no other settings. It is the shortest way to write it.

python
manager = create_memory_manager("groq:openai/gpt-oss-120b", instructions="Extract what helps support this customer. Record everything in a single Memory call.")

A model object

An object lets you set options first, such as temperature or a smaller model. The course passes an object so every run uses temperature=0.

python
model = init_chat_model("groq:openai/gpt-oss-20b", temperature=0)
manager = create_memory_manager(model, instructions="Extract what helps support this customer. Record everything in a single Memory call.")

Running without a key

Without GROQ_API_KEY the model cannot be created, so the manager fails before anything is sent:

Example
from langmem import create_memory_manager

manager = create_memory_manager("groq:openai/gpt-oss-120b")
manager.invoke({"messages": [{"role": "user", "content": "Please email me."}]})

The error comes from the line that creates the manager: LangMem builds the Groq client there, and the client needs the key. The message names the variable to set; set it as in Installation and setup and the same code runs.

The smaller model on the same conversation

When the 120b model's daily limit is used up, gpt-oss-20b has a separate budget. The same manager, with only the model string changed:

ExampleAPI key
from langchain.chat_models import init_chat_model
from langmem import create_memory_manager

model = init_chat_model("groq:openai/gpt-oss-20b", temperature=0)
manager = create_memory_manager(model, instructions="Extract what helps support this customer. Record everything in a single Memory call.")
conversation = [
    {"role": "user", "content": "Hi, my name is Asha. Order A-1001 arrived broken."},
    {"role": "assistant", "content": "Sorry to hear that. How should we contact you?"},
    {"role": "user", "content": "Please email me, I work nights."},
]
for memory in manager.invoke({"messages": conversation}):
    print(memory.content.content)

What changed with the smaller model

  • The code did not change, only the model string. Every LangMem function works the same way with any chat model.
  • The same three facts came out: the broken order, email, and the night shifts, as with the 120b model in Extracting memories.
  • It added an instruction Asha never gave: follow-ups "scheduled for nighttime hours". Both models inferred something from "I work nights"; read memories as the model's interpretation, not a transcript.

One tool call per reply vs parallel tool calls

gpt-oss on GroqModels with parallel tool calls
Tool calls in one replyOneSeveral
LangMem's default promptOften fails with a 400Works as the docs show
What to doAsk for a single Memory call, or use a profile schemaNothing extra
Examplesopenai/gpt-oss-120b, openai/gpt-oss-20bThe docs' examples use Anthropic's Claude

Choosing a model for memory

  • For extraction, pick a model that is good at tool calling; the prose quality of its replies matters less.
  • Use the same model in development and production. A manager tuned on one model can keep different things on another.
  • Keep a cheaper model for background extraction if the main agent needs the larger one.
Watch out. A model id can be retired by its provider. When a call fails with model_not_found or decommissioned, check the provider's models page and change the string.
Try it yourself
  • Pass the model as the string "groq:openai/gpt-oss-120b" with the instructions and extract Asha's memory.
  • Set temperature=1 and run the extraction three times.
  • Print model.model_name for the object you created.

This is what real progress feels like.