Chat models
One interface for OpenAI, Claude, Gemini and Ollama. Swap the provider without rewriting your calls.
Last updated
Analogy
An ORM for models. Change the driver, keep your queries.
Code example
import { ChatOpenAI } from "@langchain/openai"; const model = new ChatOpenAI({ model: "gpt-4o-mini", temperature: 0 });const reply = await model.invoke("Explain checkpoints in one line.");In an agent
Your agent graph can switch models per node: a small one for routing, a big one for reasoning.
Questions people ask
How do I switch between OpenAI, Claude and Gemini in LangChain?
Use LangChain's chat model classes, such as ChatOpenAI or ChatAnthropic. They share one interface, so model.invoke works the same for each provider. Changing providers means changing the class and its settings, not rewriting every call. It works like an ORM, where you swap the database driver but keep your queries.
Can an agent use different models for different steps?
Yes, and it often should. A small, cheap model can handle routing and simple steps, while a larger model handles the hard reasoning. In LangGraph each node can call its own chat model. Because the interface is shared, mixing models adds little code and can cut costs noticeably.