Chat models
Features (natively supported)
All ChatModels implement the Runnable interface, which comes with default implementations of all methods, ie. invoke
, batch
, stream
. This gives all ChatModels basic support for invoking, streaming and batching, which by default is implemented as below:
- Streaming support defaults to returning an
AsyncIterator
of a single value, the final result returned by the underlying ChatModel provider. This obviously doesn't give you token-by-token streaming, which requires native support from the ChatModel provider, but ensures your code that expects an iterator of tokens can work for any of our ChatModel integrations. - Batch support defaults to calling the underlying ChatModel in parallel for each input. The concurrency can be controlled with the
maxConcurrency
key inRunnableConfig
.
Each ChatModel integration can optionally provide native implementations to truly enable invoke, streaming or batching requests.
Additionally, some chat models support additional ways of guaranteeing structure in their outputs by allowing you to pass in a defined schema.
Tool calling (tool calling) is one capability, and allows you to use the chat model as the LLM in certain types of agents.
Some models in LangChain have also implemented a withStructuredOutput()
method that unifies many of these different ways of constraining output to a schema.
The table shows, for each integration, which features have been implemented with native support. Yellow circles (🟡) indicates partial support - for example, if the model supports tool calling but not tool messages for agents.
Model | Stream | JSON mode | Tool Calling | withStructuredOutput() | Multimodal |
---|---|---|---|---|---|
BedrockChat | ✅ | ❌ | 🟡 (Bedrock Anthropic only) | 🟡 (Bedrock Anthropic only) | 🟡 (Bedrock Anthropic only) |
ChatBedrockConverse | ✅ | ❌ | ✅ | ✅ | ✅ |
ChatAlibabaTongyi | ❌ | ❌ | ❌ | ❌ | ❌ |
ChatAnthropic | ✅ | ❌ | ✅ | ✅ | ✅ |
ChatBaiduWenxin | ❌ | ❌ | ❌ | ❌ | ❌ |
ChatCloudflareWorkersAI | ✅ | ❌ | ❌ | ❌ | ❌ |
ChatCohere | ✅ | ❌ | ✅ | ✅ | ✅ |
ChatFireworks | ✅ | ✅ | ✅ | ✅ | ✅ |
ChatGoogleGenerativeAI | ✅ | ❌ | ✅ | ✅ | ✅ |
ChatVertexAI | ✅ | ❌ | ✅ | ✅ | ✅ |
ChatGroq | ✅ | ✅ | ✅ | ✅ | ✅ |
ChatLlamaCpp | ✅ | ❌ | ❌ | ❌ | ❌ |
ChatMinimax | ❌ | ❌ | ❌ | ❌ | ❌ |
ChatMistralAI | ❌ | ✅ | ✅ | ✅ | ✅ |
ChatOllama | ✅ | ✅ | ✅ | ✅ | ✅ |
ChatOpenAI | ✅ | ✅ | ✅ | ✅ | ✅ |
ChatTencentHunyuan | ✅ | ❌ | ❌ | ❌ | ❌ |
ChatTogetherAI | ✅ | ✅ | ✅ | ✅ | ✅ |
ChatYandexGPT | ❌ | ❌ | ❌ | ❌ | ❌ |
ChatZhipuAI | ❌ | ❌ | ❌ | ❌ | ❌ |
All chat models
Label | Description |
---|---|
Alibaba Tongyi | LangChain.js supports the Alibaba qwen family of models. |
Anthropic | Anthropic is an AI safety and research |
Anthropic Tools | This API is deprecated as Anthropic now officially supports tools. Cl... |
Azure OpenAI | [Azure |
Baidu Qianfan | Setup |
Baidu Wenxin | This class has been deprecated. |
Amazon Bedrock | Amazon Bedrock is a fully managed |
Amazon Bedrock Converse | [Amazon Bedrock |
Cloudflare Workers AI | Workers AI allows you |
Cohere | Cohere is a Canadian startup that provides |
Deep Infra | LangChain supports chat models hosted by Deep Infra through the ChatD... |
Fake LLM | LangChain provides a fake LLM chat model for testing purposes. This a... |
Fireworks | Fireworks AI is an AI inference platform to run |
Friendli | Friendli enhances AI application performance and optimizes cost savin... |
Google GenAI | Google AI offers a number of different chat |
(Legacy) Google PaLM/VertexAI | The Google PaLM API is deprecated and will be removed in 0.3.0. Pleas... |
Google Vertex AI | Google Vertex is a service that |
Groq | Groq is a company that offers fast AI inference, |
Llama CPP | Only available on Node.js. |
Minimax | Minimax is a Chinese startup that provides natural language processin... |
MistralAI | Mistral AI is a platform that offers hosting for |
Moonshot | LangChain.js supports the Moonshot AI family of models. |
NIBittensorChatModel | This module has been deprecated and is no longer supported. The docum... |
Ollama | Ollama allows you to run open-source large |
Ollama Functions | The LangChain Ollama integration package has official support for too... |
OpenAI | OpenAI is an artificial |
PremAI | Setup |
PromptLayer OpenAI | You can pass in the optional returnPromptLayerId boolean to get a pro... |
Tencent Hunyuan | LangChain.js supports the Tencent Hunyuan family of models. |
Together | Together AI offers an API to query [50+ |
WebLLM | Only available in web environments. |
YandexGPT | LangChain.js supports calling YandexGPT chat models. |
ZhipuAI | LangChain.js supports the Zhipu AI family of models. |