---
type: study
created: 2026-08-11
updated: 2026-08-11
sensitivity: standard
status: evergreen
tags: [langchain, python, chat-models, routing, local-inference, api]
topic: LangChain Python 专业 Chat API、路由器与本地推理集成
sources:
  - https://docs.langchain.com/oss/python/integrations/chat/anthropic_functions
  - https://docs.langchain.com/oss/python/integrations/chat/baseten
  - https://docs.langchain.com/oss/python/integrations/chat/cerebras
  - https://docs.langchain.com/oss/python/integrations/chat/cohere
  - https://docs.langchain.com/oss/python/integrations/chat/crusoe
  - https://docs.langchain.com/oss/python/integrations/chat/databricks
  - https://docs.langchain.com/oss/python/integrations/chat/deepseek
  - https://docs.langchain.com/oss/python/integrations/chat/fireworks
  - https://docs.langchain.com/oss/python/integrations/chat/groq
  - https://docs.langchain.com/oss/python/integrations/chat/huggingface
  - https://docs.langchain.com/oss/python/integrations/chat/litellm
  - https://docs.langchain.com/oss/python/integrations/chat/mistralai
  - https://docs.langchain.com/oss/python/integrations/chat/ollama
  - https://docs.langchain.com/oss/python/integrations/chat/openrouter
  - https://docs.langchain.com/oss/python/integrations/chat/parallel
  - https://docs.langchain.com/oss/python/integrations/chat/perplexity
  - https://docs.langchain.com/oss/python/integrations/chat/qwen
  - https://docs.langchain.com/oss/python/integrations/chat/qwq
  - https://docs.langchain.com/oss/python/integrations/chat/sambanova
  - https://docs.langchain.com/oss/python/integrations/chat/together
  - https://docs.langchain.com/oss/python/integrations/chat/upstage
  - https://docs.langchain.com/oss/python/integrations/chat/vllm
  - https://docs.langchain.com/oss/python/integrations/chat/xai
last_verified: 2026-08-11
---

# Chat 模型：专业 API、路由与本地推理

## 快速比较

下表的“支持”仅反映 2026-08-11 LangChain 文档中的集成类能力，不保证任意 model ID 都实现。

| 类 / 包 | 能力摘要 | 限制与适用场景 |
|---|---|---|
| `ChatAnthropicTools` / `langchain-anthropic.experimental` | 工具绑定、结构化输出 | 页面明确标记 deprecated；新项目改用 `ChatAnthropic.bind_tools` / 当前 structured output API |
| `ChatBaseten` / `langchain-baseten` | tool/schema、图像/音频、stream/async/usage | 能力由部署的具体模型决定；无视频/logprobs 标记 |
| `ChatCerebras` / `langchain-cerebras` | tool/schema、stream/async/usage | 无多模态/logprobs 标记；突发并发要配合 provider 限流 |
| `ChatCohere` / `langchain-cohere` | Chat 与 tool calling | 页面无完整能力表；上线前自行补齐 stream/schema/usage 契约测试 |
| `ChatCrusoe` / `langchain-crusoe` | tool/schema、stream/async/usage | 无多模态/logprobs 标记；可用模型列表和参数应在启动时校验 |
| `ChatDatabricks` / `databricks-langchain` | tool/schema、stream/async/usage，支持自定义/外部 endpoint | 需 serving endpoint；无多模态/logprobs 标记，自定义 endpoint 契约由部署者承担 |
| `ChatDeepSeek` / `langchain-deepseek` | tool/schema、stream/async/usage | 无多模态/logprobs 标记；用专用类保留 reasoning 扩展，不用通用 `ChatOpenAI` 代理 |
| `ChatFireworks` / `langchain-fireworks` | tool/schema、stream/async/usage/logprobs，reasoning effort | 无多模态标记；需 pin model/endpoint 和限制 logprobs 返回大小 |
| `ChatGroq` / `langchain-groq` | tool/schema、图像、stream/async/usage/logprobs | 视觉取决模型；无音频/视频标记 |
| `ChatHuggingFace` / `langchain-huggingface` | tool/schema，图像/音频/视频，usage | 文档表示 token-level streaming 和 native async 不完整；后端可是 Endpoint 或本地 Pipeline，运维特性不同 |
| `ChatLiteLLM` / `ChatLiteLLMRouter` | tools/schema、图像/音频、stream/async/usage/logprobs，Vertex grounding | 路由配置会同时引入多 provider 凭据与异质能力；需锁定 fallback 和成本 |
| `ChatMistralAI` / `langchain-mistralai` | tool/schema、stream/async/usage | 无多模态/logprobs 标记 |
| `ChatOllama` / `langchain-ollama` | tool/schema、图像、stream/async/logprobs，reasoning/custom roles | 能力表不标 token usage；模型 tag、显存、并发和冷启动由本地运维承担 |
| `ChatOpenRouter` / `langchain-openrouter` | tools/strict schema、reasoning、图像/音频/视频、stream/async/usage/logprobs | 多 provider 路由可改变数据地域、特性和成本；应配 allowlist 和路由可观测 |
| `ChatParallel` / `langchain-parallel` | 研究模型 structured output、citations、stream/async | 无 tool calling/多模态/token usage/logprobs；structured output 仅研究模型，错误处理与引用是主要契约 |
| `ChatPerplexity` / `langchain-perplexity` | search metadata/citations、stream、usage，tier 3+ structured output、Agent API 模式 | 无 tool calling/多模态/native async/logprobs；账户层级会改变能力 |
| `ChatQwen` / `langchain-qwq` | tools/schema、图像/视频、stream/async/usage | 无音频/logprobs 标记；Qwen 与 QwQ 共包但类和模型定位不同 |
| `ChatQwQ` / `langchain-qwq` | tools/schema、图像/视频、stream/async/usage | 同上；不从 reasoning 品牌名假设特定字段形状 |
| `ChatSambaNova` / `langchain-sambanova` | tools/schema、图像/音频、stream/async/usage | 无视频/logprobs 标记；多模态依具体模型 |
| `ChatTogether` / `langchain-together` | tools/schema、图像/音频/视频、stream/usage/logprobs | 能力表标 native async 为否；在 async web 服务中需实测 SDK 是否阻塞 |
| `ChatUpstage` / `langchain-upstage` | Solar Chat、chain | 文档无完整能力表；不根据同 provider 的 embedding/parser 能力反推 Chat |
| vLLM via `ChatOpenAI` / `langchain-openai` | OpenAI-compatible 本地 Chat endpoint | 页面是兼容接入，无完整能力表；非标准 reasoning/usage/tool 字段可丢失，应契约测试 server 版本 |
| `ChatXAI` / `langchain-xai` | tool/schema、web search、reasoning effort、stream/usage/logprobs | 无多模态/native async 标记；web search 引用与外部内容安全需另行处理 |

## 选型建议

- 需 provider 扩展字段（reasoning、citation、search metadata、safety）时，使用专用包；仅普通文本对话且已做兼容测试时，才用 `ChatOpenAI(base_url=...)`。
- 需路由/fallback 时优先专用 router 类，并将每个候选模型纳入同一套工具/schema/安全/成本回归测试。
- 需数据不出域或稳定单位成本时选本地 Hugging Face/Ollama/vLLM，但要把模型服务当独立生产系统运维，不是开发机进程。
- 搜索/研究产品应优先保留 citations/search metadata，不把可阅读文本当成无来源事实。

## 运行时风险

1. 在 async FastAPI 路径中，文档未标 native async 的 SDK 要经过线程池或隔离 worker，并使用有界并发，防止阻塞 event loop。
2. 流式失败可能已向用户输出部分结果；不可无条件切换另一 provider 再发一遍，否则语义重复且工具可重复。
3. 用户可控 model/base URL 会变成 SSRF、费用滥用和数据外发通道；只能从服务端 allowlist 选择。
4. 使用本地模型时要监控排队、显存/OOM、首 token、tokens/s 和 cancel；限制 context 与 max output 防止单请求占满服务。
