学习笔记 · Obsidian

独立模型服务供应商

LangChainPython

定位

这些 provider 主要通过独立 Python 包暴露 Chat、LLM、Embedding、Rerank 或搜索能力。与“大云全家桶”相比,它们往往接入快、模型特性更新快,但数据位置、账户层级、速率限制和客户端成熟度差异更大。

供应商速查

Provider包/主要组件能力重点必查风险
AI21langchain-ai21; ChatAI21、AI21LLM、ContextualAnswers、SemanticTextSplitterChat + 传统 LLM + 语义分块文档将部分能力标为 deprecated,新项目不要依赖旧类
AI/ML APIlangchain-aimlapi; ChatAIMLAPI、AIMLAPILLM、AIMLAPIEmbeddings多模型 API网关后的真实 provider/model 会影响特性、费用与数据路由
Anthropiclangchain-anthropicClaude Chat/LLM,tool use、structured output、图像/PDF、prompt caching严格工具模式、细粒度工具流与普通 stream 需分别测试;实验性 tools wrapper 已废弃
Basetenlangchain-baseten; ChatBaseten、BasetenEmbeddings托管/自定义模型端点只有部署实现能决定工具、多模态和 schema 能力
Cerebraslangchain-cerebras; ChatCerebras低延迟 Chat、流式/异步、tool + structured output文档能力表无多模态/logprobs;必须设置并发与限流预算
Coherelangchain-cohere; ChatCohere、Cohere LLM/Embeddings/Rerank/RAG retriever生成、检索、rerank 组合provider 页混合多组件;应分开管理 generation 与 embedding/rerank 的配额和版本
DeepSeeklangchain-deepseek; ChatDeepSeektool、structured output、streaming不应用 ChatOpenAI 替代专用类,否则 reasoning 扩展字段可丢失
Fireworkslangchain-fireworks; Chat + Embeddings模型托管、tool/structured output、logprobs模型 ID 与 serverless/dedicated 端点应固定,不以账户默认值上线
Groqlangchain-groq; ChatGroq高速 Chat、tool、structured output,部分视觉图像能力取决于模型;配额、突发并发与 429 退避需实测
Mistral AIlangchain-mistralai; ChatMistralAI、MistralAIEmbeddingsChat + Embeddings文档能力表的 Chat 不含多模态/logprobs,不要从品牌模型能力反推类能力
ModelScopelangchain-modelscope-integration; Chat/Endpoint/EmbeddingsModelScope 托管端点SDK token、endpoint 版本和模型许可需同时校验
OpenAIlangchain-openai; ChatOpenAI、OpenAI/Azure LLM、EmbeddingsResponses/Chat Completions、tools、schema、多模态、streaming usage仅针对 OpenAI 官方规范;代理端点非标准字段不保留;base_url 可改变 stream_usage 默认行为
OpenRouterlangchain-openrouter; ChatOpenRouter多 provider 路由、tools/schema/reasoning/多模态应锁定路由策略和允许 provider;失败切换可改变输出契约、数据地域和成本
Parallellangchain-parallel; Chat、tools、retrievers研究模型、引用和检索Chat 文档显示无 tool calling,structured output 仅研究模型;应保留引用并验证可访问性
Perplexitylangchain-perplexity; Chat、SearchRetriever/Tool、Embeddings带搜索证据的回答structured output 需特定账户层级;搜索结果/引用元数据是产品契约的一部分
Pipeshiftlangchain-pipeshift; ChatPipeshift、Pipeshift LLMChat + 传统 LLM文档能力较少,上线前要补齐 timeout/retry/stream/schema 实测
PredictionGuardlangchain-predictionguard; Chat/LLM/EmbeddingsPII、prompt injection、toxicity、factuality 等防护防护结果应 fail-closed 还是降级必须明确;不能将它当作业务授权替代品
Replicatereplicate调用 Replicate 模型输入/输出 schema 由模型版本决定;必须 pin version,处理异步任务、超时和费用上限
SambaNovalangchain-sambanova; Chat + Embeddingstool/schema、stream/async、图像/音频多模态与 async 要用目标模型实测;账户限流不应共用无界重试
Togetherlangchain-together; ChatTogether、Together LLM/Embeddings多模型托管、多模态Chat 能力表显示 native async 为否,应避免在 async 服务中默认假设非阻塞 I/O
Upstagelangchain-upstage; Chat、Embeddings、Document Parse、GroundednessSolar + 文档处理/RAG各组件应分开超时和配额;文档解析结果不能默认视为完整或安全
Voyage AIlangchain-voyageai; VoyageAIEmbeddings、VoyageAIRerank检索向量 + rerankembedding 和 reranker 必须分别固定模型;换模型需全量重建/重评估
xAIlangchain-xai; ChatXAItool/schema、web search、reasoningChat 文档能力表无多模态且无 native async;搜索工具需额外的数据与引用策略

接入契约

  • 每个 provider 的 package 版本单独锁定;不要仅升级 langchain 就假设集成包同步兼容。
  • 用统一应用内部类型封装 model ID、timeout、retry、temperature/max output、stream 和 trace metadata,但保留 provider-specific response metadata,不强行丢弃 reasoning/citation/safety 字段。
  • 对 400/401/403/404 默认不重试;对 429/5xx 只在请求幂等、剩余 deadline 足够且服务端未接受工具副作用时进行有界重试。
  • 建立“最小能力”契约测试:普通 invoke、stream 终止、usage、一个工具、一个严格 schema、一个拒答/安全结果;多模态产品再增加 URL/base64/file 输入边界。

不应混为一件事的能力

Chat 生成、web search、embedding、rerank、文档解析和安全审核是不同的可用性与费用域。即使同一 provider 包同时提供这些类,也应分开配额、超时、熔断、敏感数据授权与 SLO,避免一个检索故障拖垮所有对话请求。