Chat models
Chat models are language models that use a sequence of messages as inputs and return messages as outputs (as opposed to using plain text). These are generally newer models.
info
If you'd like to write your own chat model, see this how-to. If you'd like to contribute an integration, see Contributing integrations.
Select chat model:
pip install -qU langchain-openai
import getpass
import os
if not os.environ.get("OPENAI_API_KEY"):
os.environ["OPENAI_API_KEY"] = getpass.getpass("Enter API key for OpenAI: ")
from langchain_openai import ChatOpenAI
model = ChatOpenAI(model="gpt-4o-mini")
model.invoke("Hello, world!")
Featured Providersโ
info
While all these LangChain classes support the indicated advanced feature, you may have to open the provider-specific documentation to learn which hosted models or backends support the feature.
Provider | Tool calling | Structured output | JSON mode | Local | Multimodal | Package |
---|---|---|---|---|---|---|
ChatAnthropic | โ | โ | โ | โ |