Skip to content
LangChain 文档版本 跟随上游 源快照 122e176f 更新于 2026-10-08

聊天模型集成

使用 LangChain Python 与聊天模型集成。

聊天模型是使用一系列消息作为输入并返回消息作为输出的语言模型

(与传统的明文 LLM 相对)

.

精选模型

INFO

虽然这些 LangChain 类支持所标出的高级功能,但你可能需要参考服务商专属文档,以了解哪些托管模型或后端支持该功能。

| 模型 | 流式传输 | [工具调用](/langchain/oss/python/langchain/tools) | [结构化输出](/langchain/oss/python/langchain/structured-output) | [多模态](/langchain/oss/python/langchain/messages#多模态) | 下载量 | | :- | :- | :- | :- | :- | :- | | [`AzureChatOpenAI`](https://docs.langchain.com/oss/python/integrations/chat/azure_chat_openai) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatOpenAI`](https://docs.langchain.com/oss/python/integrations/chat/openai) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatVertexAI`](https://docs.langchain.com/oss/python/integrations/chat/google_vertex_ai) (已弃用) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatAnthropic`](https://docs.langchain.com/oss/python/integrations/chat/anthropic) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatGoogleGenerativeAI`](https://docs.langchain.com/oss/python/integrations/chat/google_generative_ai) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatOllama`](https://docs.langchain.com/oss/python/integrations/chat/ollama) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatDatabricks`](https://docs.langchain.com/oss/python/integrations/chat/databricks) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatGroq`](https://docs.langchain.com/oss/python/integrations/chat/groq) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatHuggingFace`](https://docs.langchain.com/oss/python/integrations/chat/huggingface) | ❌ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatLiteLLM`](https://docs.langchain.com/oss/python/integrations/chat/litellm) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatMistralAI`](https://docs.langchain.com/oss/python/integrations/chat/mistralai) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatOpenRouter`](https://docs.langchain.com/oss/python/integrations/chat/openrouter) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatCohere`](https://docs.langchain.com/oss/python/integrations/chat/cohere) | | | | | 每月下载量 | | [`ChatXAI`](https://docs.langchain.com/oss/python/integrations/chat/xai) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatNVIDIA`](https://docs.langchain.com/oss/python/integrations/chat/nvidia_ai_endpoints) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatDeepSeek`](https://docs.langchain.com/oss/python/integrations/chat/deepseek) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatTogether`](https://docs.langchain.com/oss/python/integrations/chat/together) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatAmazonNova`](https://docs.langchain.com/oss/python/integrations/chat/amazon_nova) | ✅ | ✅ | ✅ | | 每月下载量 |

请参阅下方聊天模型集成的完整列表以了解更多选项。

路由器与代理

路由器和代理让你通过单一 API 和凭据访问来自多个服务商的模型。它们可以简化计费,让你在无需更改集成的情况下切换模型,并提供自动回退等功能。

服务商集成描述
Agentic SpendGuardSpendGuardChatModel运行时预算闸门,在 LLM 调用到达服务商之前拒绝会超出支出限额的调用
Alephant AIChatAlephantAI用于成本控制、自带密钥路由以及访问多个服务商的模型的 AI 网关
OpenRouterChatOpenRouter统一访问来自 OpenAI、Anthropic、Google、Meta 等的模型
LiteLLMChatLiteLLMRouter面向 OpenAI、Anthropic、Azure、Hugging Face 等的统一接口,支持路由和回退

Chat Completions API

某些模型服务商提供与 OpenAI 的 Chat Completions API 兼容的端点。在这种情况下,你可以使用带自定义 base_url 的 ChatOpenAI 连接到这些端点,以实现基本聊天功能。

WARNING

ChatOpenAI 仅针对官方 OpenAI API 规范。来自第三方服务商的非标准响应字段(例如 reasoning_content、reasoning、reasoning_details)不会被提取或保留。当你需要访问非标准功能时,请使用服务商专属的包。

例如,OpenRouter 有专门的 LangChain 集成。请参阅 ChatOpenRouter 指南以了解设置和用法。

Snowflake Cortex REST API 与 OpenAI 和 Anthropic 的 API 完全兼容。使用带自定义 base_url 的 ChatOpenAI 或 ChatAnthropic,即可访问运行在 Snowflake 安全边界内的前沿模型。

Auxen 托管了每位客户专属的 LLM 端点,提供 OpenAI 兼容的 Chat Completions API。使用带自定义 base_url 和按实例区分的 API key 的 ChatOpenAI。

DaoXE 是一个多模型 API 网关,提供 OpenAI 兼容的 Chat Completions 接口。使用带 base_url https://daoxe.com/v1 和账户范围内的模型 ID 的 ChatOpenAI。

1Claw 通过 Shroud TEE 代理路由 LLM 调用,使用 ChatOpenAI 或 ChatAnthropic 以及自定义 base_url,使服务商密钥和机密不进入智能体上下文。

Apertis 提供 OpenAI 兼容的 Chat Completions API。使用带 base_url https://api.apertis.ai/v1 和你的账户可用的模型 ID 的 ChatOpenAI。

AI Power Grid 将 OpenAI 兼容的 Chat Completions 路由到社区运营的模型 worker。使用带 base_url https://api.aipowergrid.io/v1 和账户范围内的 API key 的 ChatOpenAI。

Tuning Engines 提供受治理的 OpenAI 兼容 Chat Completions API。使用带 base_url https://api.tuningengines.com/v1 和 Tuning Engines 推理密钥的 ChatOpenAI。

所有聊天模型

| 模型 | 流式传输 | [工具调用](/langchain/oss/python/langchain/tools) | [结构化输出](/langchain/oss/python/langchain/structured-output) | [多模态](/langchain/oss/python/langchain/messages#多模态) | 下载量 | | :- | :- | :- | :- | :- | :- | | [`AzureChatOpenAI`](https://docs.langchain.com/oss/python/integrations/chat/azure_chat_openai) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatOpenAI`](https://docs.langchain.com/oss/python/integrations/chat/openai) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`vLLM`](https://docs.langchain.com/oss/python/integrations/chat/vllm) | | | | | 每月下载量 | | [`ChatAnthropicVertex`](https://docs.langchain.com/oss/python/integrations/chat/google_anthropic_vertex) | | | | | 每月下载量 | | [`ChatVertexAI`](https://docs.langchain.com/oss/python/integrations/chat/google_vertex_ai) (已弃用) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatAnthropic`](https://docs.langchain.com/oss/python/integrations/chat/anthropic) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatAnthropicTools`](https://docs.langchain.com/oss/python/integrations/chat/anthropic_functions) | | | | | 每月下载量 | | [`ChatGoogleGenerativeAI`](https://docs.langchain.com/oss/python/integrations/chat/google_generative_ai) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatBedrock`](https://docs.langchain.com/oss/python/integrations/chat/bedrock) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatOllama`](https://docs.langchain.com/oss/python/integrations/chat/ollama) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatDatabricks`](https://docs.langchain.com/oss/python/integrations/chat/databricks) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatGroq`](https://docs.langchain.com/oss/python/integrations/chat/groq) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatHuggingFace`](https://docs.langchain.com/oss/python/integrations/chat/huggingface) | ❌ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatLiteLLM`](https://docs.langchain.com/oss/python/integrations/chat/litellm) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`AzureAIChatCompletionsModel`](https://docs.langchain.com/oss/python/integrations/chat/azure_ai) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatFireworks`](https://docs.langchain.com/oss/python/integrations/chat/fireworks) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatMistralAI`](https://docs.langchain.com/oss/python/integrations/chat/mistralai) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatOpenRouter`](https://docs.langchain.com/oss/python/integrations/chat/openrouter) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatCohere`](https://docs.langchain.com/oss/python/integrations/chat/cohere) | | | | | 每月下载量 | | [`ChatXAI`](https://docs.langchain.com/oss/python/integrations/chat/xai) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatNVIDIA`](https://docs.langchain.com/oss/python/integrations/chat/nvidia_ai_endpoints) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatDeepSeek`](https://docs.langchain.com/oss/python/integrations/chat/deepseek) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatWatsonx`](https://docs.langchain.com/oss/python/integrations/chat/ibm_watsonx) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatPerplexity`](https://docs.langchain.com/oss/python/integrations/chat/perplexity) | ✅ | ❌ | ✅ | ❌ | 每月下载量 | | [`ChatCerebras`](https://docs.langchain.com/oss/python/integrations/chat/cerebras) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatBaseten`](https://docs.langchain.com/oss/python/integrations/chat/baseten) | | | | | 每月下载量 | | [`ChatOCIGenerativeAI`](https://docs.langchain.com/oss/python/integrations/chat/oci_generative_ai) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatOCIModelDeployment`](https://docs.langchain.com/oss/python/integrations/chat/oci_data_science) | ✅ | | | | 每月下载量 | | [`ChatTogether`](https://docs.langchain.com/oss/python/integrations/chat/together) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatSambaNova`](https://docs.langchain.com/oss/python/integrations/chat/sambanova) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatQwen`](https://docs.langchain.com/oss/python/integrations/chat/qwen) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatQwQ`](https://docs.langchain.com/oss/python/integrations/chat/qwq) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatUpstage`](https://docs.langchain.com/oss/python/integrations/chat/upstage) | | | | | 每月下载量 | | [`ChatMoonshot`](https://github.com/ArcadiaLin/langchain-moonshot) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatClovaX`](https://guide.ncloud-docs.com/docs/clovastudio-dev-langchain) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatAI21`](https://docs.ai21.com/home) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatParallel`](https://docs.langchain.com/oss/python/integrations/chat/parallel) | ✅ | ❌ | ✅ | ❌ | 每月下载量 | | [`ChatCloudflareWorkersAI`](https://github.com/cloudflare/langchain-cloudflare) | ❌ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatNebius`](https://github.com/nebius/langchain-nebius) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatAmazonNova`](https://docs.langchain.com/oss/python/integrations/chat/amazon_nova) | ✅ | ✅ | ✅ | | 每月下载量 | | [`ChatGradient`](https://docs.digitalocean.com/products/ai-platform/) | | | | | 每月下载量 | | [`ChatAimlapi`](https://docs.aimlapi.com/) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatWriter`](https://dev.writer.com/home/introduction) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`Apertis`](https://docs.apertis.ai/api/sdks/langchain/) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatHubris`](https://hubris.pw/docs/integrations/langchain) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatInterfaze`](https://interfaze.ai/docs) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatContextual`](https://docs.contextual.ai/) | ❌ | ❌ | ❌ | ❌ | 每月下载量 | | [`ChatCrusoe`](https://docs.langchain.com/oss/python/integrations/chat/crusoe) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatOpenZoo`](https://github.com/staccDOTsol/langchain-openzoo) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatPredictionGuard`](https://github.com/predictionguard/langchain-predictionguard) | | | | | 每月下载量 | | [`ChatBrainiall`](https://app.brainiall.com/docs) | | | | | 每月下载量 | | [`ChatXinference`](https://github.com/TheSongg/langchain-xinference) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatKinetica`](https://github.com/kineticadb/langchain-kinetica) | | | | | 每月下载量 | | [`ChatRunPod`](https://docs.runpod.io/overview) | | | | | 每月下载量 | | [`ChatSarvam`](https://docs.sarvam.ai/api/integration/langchain) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatKServe`](https://gitlab.com/bitkaio/langchain/kserve-provider) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatFeatherlessAI`](https://github.com/featherless-ai-integrations/langchain-featherless-ai) | ✅ | ❌ | ❌ | ❌ | 每月下载量 | | [`ChatAbso`](https://github.com/lunary-ai/langchain-abso) | | | | | 每月下载量 | | [`ChatDiffbot`](https://github.com/diffbot/langchain-diffbot) | ✅ | ❌ | ❌ | ❌ | 每月下载量 | | [`ChatYutoriNavigator`](https://docs.yutori.com) | | | | | 每月下载量 | | [`ChatDoubleword`](https://docs.doubleword.ai/inference-api/intro-to-doubleword-inference) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ModelScopeChatEndpoint`](https://github.com/modelscope/langchain-modelscope) | | | | | 每月下载量 | | [`ChatAppleFoundationModels`](https://github.com/rajanshxrma/langchain-apple-foundation-models) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`SpendGuardChatModel`](https://agenticspendguard.dev) | | | | | 每月下载量 | | [`ChatAlephantAI`](https://alephant.io/) | | | | | 每月下载量 | | [`ChatPipeshift`](https://github.com/pipeshift-org/langchain-pipeshift) | ✅ | ❌ | ❌ | ✅ | 每月下载量 | | [`ChatDuel`](https://duelagents.com) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatNetmind`](https://github.com/protagolabs/langchain-netmind) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatNeuralwatt`](https://neuralwatt.com) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatSeekrFlow`](https://github.com/benfaircloth/langchain-seekrflow) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`ChatThalam`](https://thalam.ai/docs) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatGreenNode`](https://github.com/greennode-ai/langchain-greennode) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatEmpirioLabs`](https://docs.empiriolabs.ai) | ✅ | ✅ | ✅ | ✅ | 每月下载量 | | [`ChatKalibr`](https://kalibr.systems/docs) | | | | | 每月下载量 | | [`ChatTelnyx`](https://developers.telnyx.com/docs/inference/models) | ✅ | ✅ | ✅ | ❌ | 每月下载量 | | [`1Claw`](https://docs.1claw.xyz) | ✅ | ✅ | ✅ | ❌ | N/A | | [`Auxen`](https://auxen.ai) | ✅ | ✅ | ✅ | ❌ | N/A | | [`Cheaper Inference`](https://cheaperinference.com/docs) | ✅ | ✅ | ✅ | ✅ | N/A | | [`DaoXE`](https://daoxe.com) | ✅ | ✅ | ✅ | ✅ | N/A | | [`FuturMix`](https://futurmix.ai/) | ✅ | ✅ | ✅ | ✅ | N/A | | [`Snowflake Cortex REST API`](https://docs.snowflake.com/en/user-guide/snowflake-cortex/cortex-rest-api) | ✅ | ✅ | ✅ | ❌ | N/A | | [`Synthorai`](https://synthorai.io/docs/) | | | | | N/A | | [`TokenMix`](https://tokenmix.ai/docs) | ✅ | ✅ | ✅ | ❌ | N/A | | [`Tuning Engines`](https://www.tuningengines.com/) | ✅ | ✅ | ✅ | ❌ | N/A |

INFO

如果你想贡献一个集成,请参阅贡献集成。


BytesRouter 是社区翻译站点,所有译文仅供参考,一切以官方英文原文为准。