Skip to content

Chat models

A chat model accepts messages and returns an AIMessage. init_chat_model() selects a provider integration from a model identifier; provider packages still handle credentials and provider-specific options.

from langchain.chat_models import init_chat_model
model = init_chat_model(
"openai:gpt-5.4-mini",
temperature=0,
timeout=20,
max_retries=2,
)
reply = model.invoke("Summarize ticket INC-104 in one sentence.")
print(reply.text)
  1. Pick a provider and model.
  2. Set a timeout and retry limit.
  3. Send messages.
  4. Read the returned AIMessage and usage metadata.

A common interface does not make models interchangeable. Tool calling, structured output, token limits, pricing, and multimodal support differ. Check the selected provider integration and evaluate the exact model version.

Messages · invoke and ainvoke · Structured output