---
type: study
created: 2026-08-11
updated: 2026-08-11
sensitivity: standard
status: verified
tags:
  - study
  - langchain
  - typescript
  - integrations
  - chat-models
  - local-models
  - testing
topic: LangChain JavaScript 其他云本地与测试 Chat 模型
sources:
  - https://docs.langchain.com/oss/javascript/integrations/chat/baidu_qianfan
  - https://docs.langchain.com/oss/javascript/integrations/chat/cerebras
  - https://docs.langchain.com/oss/javascript/integrations/chat/cloudflare_workersai
  - https://docs.langchain.com/oss/javascript/integrations/chat/deepseek
  - https://docs.langchain.com/oss/javascript/integrations/chat/fake
  - https://docs.langchain.com/oss/javascript/integrations/chat/fireworks
  - https://docs.langchain.com/oss/javascript/integrations/chat/groq
  - https://docs.langchain.com/oss/javascript/integrations/chat/ollama
  - https://docs.langchain.com/oss/javascript/integrations/chat/perplexity
  - https://docs.langchain.com/oss/javascript/integrations/chat/togetherai
  - https://docs.langchain.com/oss/javascript/integrations/chat/xai
  - https://docs.langchain.com/oss/javascript/integrations/chat/yandex
last_verified: 2026-08-11
---
# Chat 模型：其他云、本地与测试

## 能力矩阵

“I/A/V”依次为图片、音频、视频输入。`—` 表示组件页没有标准 feature table，不能按空白推断支持或不支持。

| 类 / 包 | 认证 | Tool | Structured | I/A/V | Stream | Usage / Logprobs | 备注 |
|---|---|---:|---:|---|---:|---|---|
| `ChatBaiduQianfan` / `@langchain/baidu-qianfan` | Qianfan access + secret key | — | — | — | 文档示例支持 | — | 旧格式页面；`ERNIE-Bot-turbo` 标为 abandoned |
| `ChatCerebras` / `@langchain/cerebras` | `CEREBRAS_API_KEY` | ✅ | ✅ | ❌/❌/❌ | ✅ | ✅/❌ | 不可序列化 |
| `ChatCloudflareWorkersAI` / `@langchain/cloudflare` | account id + API token | ❌ | ❌ | ✅/❌/❌ | ✅ | ❌/❌ | 可配置 AI Gateway base URL；模型级多模态需核验 |
| `ChatDeepSeek` / `@langchain/deepseek` | `DEEPSEEK_API_KEY` | ✅ | ✅ | ❌/❌/❌ | ✅ | ✅/✅ | serializable 标为 beta |
| `FakeListChatModel` / `@langchain/core/utils/testing` | 无 | — | — | — | 可模拟 | — | 有序固定响应、stream 与延迟测试；禁止作为运行时 fallback |
| `ChatFireworks` / `@langchain/fireworks` | `FIREWORKS_API_KEY` | ✅ | ✅ | ❌/❌/❌ | ✅ | ✅/✅ | 模型清单和能力由托管模型决定 |
| `ChatGroq` / `@langchain/groq` | `GROQ_API_KEY` | ✅ | ✅ | ❌/❌/❌ | ✅ | ✅/✅ | 不可序列化 |
| `ChatOllama` / `@langchain/ollama` | 本地 daemon，无 API key | ✅ | ✅ | ✅/❌/❌ | ✅ | ✅/❌ | serializable beta；需先拉取模型；模型能力差异大 |
| `ChatPerplexity` / `@langchain/perplexity` | `PERPLEXITY_API_KEY` | ❌* | ✅ | ❌/❌/❌ | ✅ | ✅/❌ | serializable beta；可切 Agent/Responses API |
| `ChatTogetherAI` / `@langchain/together-ai` | `TOGETHER_AI_API_KEY` | ✅ | ✅ | ✅/✅/✅ | ✅ | ✅/✅ | 实际能力取决于所选开源模型 |
| `ChatXAI` / `@langchain/xai` | `XAI_API_KEY` | ✅ | ✅ | ❌/❌/❌ | ✅ | ✅/✅ | serializable |
| `ChatYandexGPT` / `@langchain/yandex/chat_models` | `YC_IAM_TOKEN` 或 `YC_API_KEY` | — | — | — | — | — | 旧格式页面，无标准能力声明 |

\* Perplexity 的标准矩阵把普通 tool calling 标为否，但 Agent API 可绑定 provider built-in tools，并把返回的 tool call 放进标准字段。这是 endpoint-specific 能力，不等于任意 LangChain tool schema 都被支持。

## 初始化要点

- Baidu 通过 constructor 传 `qianfanAccessKey`、`qianfanSecretKey` 和 model；文档列出多种 ERNIE 型号，但上线前应从服务端重新获取当前可用清单。
- Cerebras、DeepSeek、Fireworks、Groq、TogetherAI 与 xAI 都是独立 provider 包；不要因为 API 形态相似而统一走 `ChatOpenAI`，否则会丢失 provider metadata 和能力约束。
- Cloudflare Chat wrapper 的示例通过 account id/token 调 Workers AI，可选 AI Gateway base URL。与 Cloudflare embedding 的 Worker binding 模式不同。
- Ollama 依赖本地服务和已下载模型；把 base URL、模型 digest、GPU/CPU 配置和并发上限视为部署配置。
- Yandex 需要具有 `ai.languageModels.user` 角色的 service account，再选 IAM token 或 API key。

## Perplexity 的双端点

`ChatPerplexity` 的 `useResponsesApi` 有三种语义：

| 值 | 路由 |
|---|---|
| 未设置 | 普通请求走 Chat Completions；出现 built-in tool 或 Responses-only 字段时自动走 Agent API |
| `true` | 始终走 Agent API |
| `false` | 始终走 Chat Completions |

Agent API 提供 web search、fetch URL、finance search、people search，以及 `previousResponseId` 等状态字段；原始 output items 位于 provider-specific metadata。生产代码要记录实际 endpoint，并避免在自动检测切换后悄悄改变数据出口、计费或保留策略。

## Fake 模型的测试价值

`FakeListChatModel` 能按顺序返回预设响应、模拟 stream 和 `sleep` 延迟。它适合验证：

- chain 编排与输出 parser；
- streaming 拼接和 client cancellation；
- timeout、loading 与重试 UI；
- 不依赖外部 API 的确定性单测。

它不模拟 token usage、provider 限流、工具 schema 差异或真实多模态，不能替代外部 contract test；生产配置应 fail closed，不能在 provider 故障时自动切 Fake 并向用户返回伪结果。

## 本地 Ollama 的生产边界

- 本地不等于安全：服务端口需要网络隔离和认证边界，不能直接暴露公网。
- 模型 tag 可移动，发布应固定模型文件/digest，并验证上下文长度、tool schema、视觉能力和量化精度。
- 预热、显存、并发队列、冷加载、OOM 与 eviction 都需监控；LangChain 的 `maxRetries` 不能解决容量不足。
- `withStructuredOutput()` 仍需应用侧 schema 校验；不同 Ollama 模型对工具和 JSON 的遵循度不同。

## 上线门禁

对没有标准 feature table 的 Baidu/Yandex 路由，只把文档明确展示的调用或 streaming 当已知能力。对聚合托管平台和 Ollama，按精确模型 ID 单独维护 capability profile；禁止把 wrapper 的勾选扩展为整个 provider 的 SLA。
