> ## Documentation Index
> Fetch the complete documentation index at: https://langchain-docs-zh.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# 聊天模型集成

> 对话模型是使用消息序列作为输入并返回消息作为输出（与纯文本相对）的语言模型。

[对话模型](https://langchain-docs-zh.mintlify.site/langchain/oss/langchain/models.md)是使用消息序列作为输入并返回消息作为输出（与纯文本相对） (Older models that do not follow the chat model interface and instead use an interface that takes a string as input and returns a string as output. These models typically do not include the prefix 'Chat' in their name or include 'LLM' as a suffix.)的语言模型。

## 安装和使用

> [!TIP]
>
> 查看[安装 LangChain 包的一般说明部分](https://langchain-docs-zh.mintlify.site/langchain/oss/langchain/install.md)。

> [accordion] OpenAI
>
> 安装:
>
> ```bash npm theme={null}
> npm install @langchain/openai @langchain/core
> ```
>
> ```bash yarn theme={null}
> yarn add @langchain/openai @langchain/core
> ```
>
> ```bash pnpm theme={null}
> pnpm add @langchain/openai @langchain/core
> ```
>
> 添加环境变量:
>
> ```bash theme={null}
> OPENAI_API_KEY=your-api-key
> ```
>
> 实例化模型:
>
> ```typescript theme={null}
> import { ChatOpenAI } from "@langchain/openai";
>
> const model = new ChatOpenAI({ model: "gpt-5.4-mini" });
> ```
>
> ```javascript theme={null}
> await model.invoke("Hello, world!")
> ```

> [accordion] Anthropic
>
> 安装:
>
> ```bash npm theme={null}
> npm i @langchain/anthropic @langchain/core
> ```
>
> ```bash yarn theme={null}
> yarn add @langchain/anthropic @langchain/core
> ```
>
> ```bash pnpm theme={null}
> pnpm add @langchain/anthropic @langchain/core
> ```
>
> 添加环境变量:
>
> ```bash theme={null}
> ANTHROPIC_API_KEY=your-api-key
> ```
>
> 实例化模型:
>
> ```typescript theme={null}
> import { ChatAnthropic } from "@langchain/anthropic";
>
> const model = new ChatAnthropic({
> model: "claude-sonnet-4-6",
> temperature: 0
> });
> ```
>
> ```javascript theme={null}
> await model.invoke("Hello, world!")
> ```

> [accordion] Google Gemini
>
> 安装:
>
> ```bash npm theme={null}
> npm install @langchain/google @langchain/core
> ```
>
> ```bash yarn theme={null}
> yarn add @langchain/google @langchain/core
> ```
>
> ```bash pnpm theme={null}
> pnpm add @langchain/google @langchain/core
> ```
>
> 添加环境变量:
>
> ```bash theme={null}
> GOOGLE_API_KEY=your-api-key
> ```
>
> 实例化模型:
>
> ```typescript theme={null}
> import { ChatGoogle } from "@langchain/google";
>
> const model = new ChatGoogle("gemini-2.5-flash");
> ```
>
> ```javascript theme={null}
> await model.invoke("Hello, world!")
> ```

> [accordion] MistralAI
>
> 安装:
>
> ```bash npm theme={null}
> npm install @langchain/mistralai @langchain/core
> ```
>
> ```bash yarn theme={null}
> yarn add @langchain/mistralai @langchain/core
> ```
>
> ```bash pnpm theme={null}
> pnpm add @langchain/mistralai @langchain/core
> ```
>
> 添加环境变量:
>
> ```bash theme={null}
> MISTRAL_API_KEY=your-api-key
> ```
>
> 实例化模型:
>
> ```typescript theme={null}
> import { ChatMistralAI } from "@langchain/mistralai";
>
> const model = new ChatMistralAI({
> model: "mistral-large-latest",
> temperature: 0
> });
> ```
>
> ```javascript theme={null}
> await model.invoke("Hello, world!")
> ```

> [accordion] Groq
>
> 安装:
>
> ```bash npm theme={null}
> npm install @langchain/groq @langchain/core
> ```
>
> ```bash yarn theme={null}
> yarn add @langchain/groq @langchain/core
> ```
>
> ```bash pnpm theme={null}
> pnpm add @langchain/groq @langchain/core
> ```
>
> 添加环境变量:
>
> ```bash theme={null}
> GROQ_API_KEY=your-api-key
> ```
>
> 实例化模型:
>
> ```typescript theme={null}
> import { ChatGroq } from "@langchain/groq";
>
> const model = new ChatGroq({
> model: "openai/gpt-oss-120b",
> temperature: 0
> });
> ```
>
> ```javascript theme={null}
> await model.invoke("Hello, world!")
> ```

## 特色模型

> [!NOTE]
>
> **虽然这些 LangChain 类支持所指示的高级功能**，但您可能需要参考提供者特定文档来了解哪些托管的模型或后端支持该功能。

| 模型 | 流式输出 | [工具调用](https://langchain-docs-zh.mintlify.site/langchain/oss/langchain/tools.md) | [`withStructuredOutput()`](https://langchain-docs-zh.mintlify.site/langchain/oss/langchain/models#结构化输出) | [`Multimodal`](https://langchain-docs-zh.mintlify.site/langchain/oss/langchain/messages#multimodal) | 下载 |
| :- | :- | :- | :- | :- | :- |
| [`ChatOpenAI`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/openai) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/openai?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/openai) |
| [`ChatAnthropic`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/anthropic) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/anthropic?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/anthropic) |
| [`ChatBedrockConverse`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/bedrock_converse) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/aws?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/aws) |
| [`ChatGroq`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/groq) | ✅ | ✅ | ✅ | ❌ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/groq?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/groq) |
| [`ChatOllama`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/ollama) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/ollama?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/ollama) |
| [`ChatMistralAI`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/mistral) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/mistralai?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/mistralai) |
| [`ChatGoogle`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/google) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/google?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/google) |
| [`ChatCohere`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/cohere) | ✅ | ✅ | ✅ | ❌ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/cohere?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/cohere) |
| [`ChatXAI`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/xai) | ✅ | ✅ | ✅ | ❌ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/xai?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/xai) |
| [`ChatFireworks`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/fireworks) | ✅ | ✅ | ✅ | ❌ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/fireworks?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/fireworks) |
| [`ChatCloudflareWorkersAI`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/cloudflare_workersai) | ✅ | ❌ | ❌ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/cloudflare?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/cloudflare) |
| [`ChatTogetherAI`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/togetherai) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/together-ai?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/together-ai) |
| [`ChatPerplexity`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/perplexity) | ✅ | ❌ | ✅ | ❌ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/perplexity?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/perplexity) |

查看[完整的对话模型集成列表](#所有对话模型)以获取更多选项。

## 路由器和代理

路由器和代理通过单个 API 和凭证提供对来自多个提供者的模型的访问。它们可以简化计费，让您在不更改集成的情况下切换模型，并提供自动回退等特性。

| 提供者 | 集成 | 描述 |
| - | - | - |
| [OpenRouter](https://openrouter.ai/) | [`ChatOpenRouter`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/openrouter) | 统一访问 OpenAI、Anthropic、Google、Meta 等模型的接口 |

## 对话完成 API

某些模型提供者提供与 OpenAI 的（旧版）[对话完成 API](https://platform.openai.com/docs/guides/completions)兼容的端点。在这种情况下，您可以使用 [`ChatOpenAI`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/openai) 并通过自定义`base_url`连接到这些端点。请注意，基于对话完成 API 构建的功能可能无法完全由`ChatOpenAI`支持；在这种情况下，如果可用，请考虑使用提供者特定的类。

## 所有对话模型

| 模型 | 流式 | [工具调用](https://langchain-docs-zh.mintlify.site/langchain/oss/langchain/tools.md) | [`withStructuredOutput()`](https://langchain-docs-zh.mintlify.site/langchain/oss/langchain/models#结构化输出) | [`Multimodal`](https://langchain-docs-zh.mintlify.site/langchain/oss/langchain/messages#multimodal) | 下载 |
| :- | :- | :- | :- | :- | :- |
| [`AzureChatOpenAI`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/azure) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/openai?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/openai) |
| [`ChatOpenAI`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/openai) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/openai?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/openai) |
| [`ChatAnthropic`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/anthropic) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/anthropic?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/anthropic) |
| [`ChatGoogleGenerativeAI`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/google_generative_ai) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/google-genai?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/google-genai) |
| [`ChatBedrockConverse`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/bedrock_converse) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/aws?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/aws) |
| [`ChatVertexAI`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/google_vertex_ai) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/google-vertexai?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/google-vertexai) |
| [`ChatGroq`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/groq) | ✅ | ✅ | ✅ | ❌ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/groq?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/groq) |
| [`ChatOllama`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/ollama) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/ollama?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/ollama) |
| [`ChatMistralAI`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/mistral) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/mistralai?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/mistralai) |
| [`ChatGoogle`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/google) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/google?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/google) |
| [`ChatCohere`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/cohere) | ✅ | ✅ | ✅ | ❌ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/cohere?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/cohere) |
| [`ChatXAI`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/xai) | ✅ | ✅ | ✅ | ❌ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/xai?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/xai) |
| [`ChatOpenRouter`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/openrouter) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/openrouter?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/openrouter) |
| [`ChatDeepSeek`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/deepseek) | ✅ | ✅ | ✅ | ❌ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/deepseek?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/deepseek) |
| [`ChatCerebras`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/cerebras) | ✅ | ✅ | ✅ | ❌ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/cerebras?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/cerebras) |
| [`ChatFireworks`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/fireworks) | ✅ | ✅ | ✅ | ❌ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/fireworks?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/fireworks) |
| [`ChatBaiduQianfan`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/baidu_qianfan) | | | | | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/baidu-qianfan?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/baidu-qianfan) |
| [`ChatCloudflareWorkersAI`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/cloudflare_workersai) | ✅ | ❌ | ❌ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/cloudflare?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/cloudflare) |
| [`ChatTogetherAI`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/togetherai) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/together-ai?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/together-ai) |
| [`ChatWatsonx`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/ibm) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/ibm?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/ibm) |
| [`ChatPerplexity`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/perplexity) | ✅ | ❌ | ✅ | ❌ | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/perplexity?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/perplexity) |
| [`ChatYandexGPT`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/yandex) | | | | | [  ![Downloads per month](https://img.shields.io/npm/dm/@langchain/yandex?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@langchain/yandex) |
| [`ChatWebLLM`](https://github.com/ykoh42/web-llm-adapters/blob/main/packages/langchain-web-llm/README.md) | ✅ | ✅ | ✅ | | [  ![Downloads per month](https://img.shields.io/npm/dm/langchain-web-llm?style=flat-square\&label=%20&)](https://www.npmjs.com/package/langchain-web-llm) |
| [`ChatEmpirioLabs`](https://docs.empiriolabs.ai/integrations#langchain) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@empiriolabs/langchain?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@empiriolabs/langchain) |
| [`ChatInterfaze`](https://interfaze.ai/docs) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@interfaze-ai/langchain?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@interfaze-ai/langchain) |
| [`ChatKServe`](https://gitlab.com/bitkaio/langchain/kserve-provider) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@bitkaio/langchain-kserve?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@bitkaio/langchain-kserve) |
| [`RecallToolkit`](https://recallmem.dev/guides/langchain) | | | | | [  ![Downloads per month](https://img.shields.io/npm/dm/@recall-memory/langchain?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@recall-memory/langchain) |
| [`ChatSCX`](https://scx.ai/) | ✅ | ✅ | ✅ | ✅ | [  ![Downloads per month](https://img.shields.io/npm/dm/@scx-ai/langchain?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@scx-ai/langchain) |
| [`ChatObscurify`](https://github.com/Obscurify-ai/langchain-obscurify) | ✅ | ✅ | ✅ | | [  ![Downloads per month](https://img.shields.io/npm/dm/@obscurify/langchain?style=flat-square\&label=%20&)](https://www.npmjs.com/package/@obscurify/langchain) |
| [`Auxen`](https://auxen.ai) | ✅ | ✅ | ✅ | ❌ | N/A |
| [`FakeListChatModel`](https://langchain-docs-zh.mintlify.site/langchain/oss/javascript/integrations/chat/fake) | | | | | N/A |
| [`Tuning Engines`](https://www.tuningengines.com/) | ✅ | ✅ | ✅ | ❌ | N/A |

> [!NOTE]
>
> 如果您希望贡献集成，请查看[贡献集成](https://langchain-docs-zh.mintlify.site/langchain/oss/contributing/integrations-langchain.md)。

***

> 官方原文：[src/oss/javascript/integrations/chat/index.mdx](https://github.com/langchain-ai/docs/blob/main/src/oss/javascript/integrations/chat/index.mdx) · 非官方翻译，译文由 AI 生成，以英文原文为准。


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.