主题
聊天模型集成
使用 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 SpendGuard | SpendGuardChatModel | 运行时预算闸门,在 LLM 调用到达服务商之前拒绝会超出支出限额的调用 |
| Alephant AI | ChatAlephantAI | 用于成本控制、自带密钥路由以及访问多个服务商的模型的 AI 网关 |
| OpenRouter | ChatOpenRouter | 统一访问来自 OpenAI、Anthropic、Google、Meta 等的模型 |
| LiteLLM | ChatLiteLLMRouter | 面向 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
如果你想贡献一个集成,请参阅贡献集成。