十年匠心定制 · 商业建站与技术教学双线并行 咨询热线:400-886-1026 service@lmnt.cn
ARTICLE DETAIL

资讯详情

深耕网站建设与运营推广的一线实战洞察。

OpenClaw 接入 Cohere 模型提供商:插件安装、API Key 配置与模型目录深度解析

OpenClaw 接入 Cohere 模型提供商:插件安装、API Key 配置与模型目录深度解析 OpenClaw 接入 Cohere 模型提供商插件安装、API Key 配置与模型目录深度解析【免费下载链接】openclawThe AI that really does things. Any OS. Any Platform. The lobster way. 项目地址: https://gitcode.com/GitHub_Trending/cl/openclaw本篇技术指南以 OpenClaw 官方文档 docs/providers/cohere.md 为主体结合仓库中extensions/cohere插件的源码与测试系统讲解如何在 OpenClaw 中安装 Cohere Provider 插件、通过 API Key 完成认证与模型选择并深入剖析内置模型目录、推理模式映射与请求流适配的底层实现。读完本文你将掌握一条从插件安装到模型上线的完整链路并理解 OpenClaw 与 Cohere Compatibility API 交互时看似 OpenAI 兼容、实则细节不同的工程处理。Cohere Provider 概览Cohere 通过其Compatibility API提供 OpenAI 兼容的推理服务因此 OpenClaw 将其归类为openai-completions一类提供商。OpenClaw 以官方外部插件形式提供 Cohere 支持核心属性如下PropertyValueProvider idcoherePluginopenclaw/cohere-providerAuth env varCOHERE_API_KEYOnboarding flag--auth-choice cohere-api-keyDirect CLI flag--cohere-api-key keyAPIOpenAI-compatible (openai-completions)Base URLhttps://api.cohere.ai/compatibility/v1Default modelcohere/command-a-plus-05-2026Context window128,000 tokens这些声明与插件清单文件 extensions/cohere/openclaw.plugin.json 保持一致插件 id 为coherebaseUrl指向https://api.cohere.ai/compatibility/v1api为openai-completions默认模型为command-a-plus-05-2026认证环境变量为COHERE_API_KEY。内置模型目录插件清单内置了 5 个 Cohere 模型条目在 OpenClaw 中以cohere/model-id形式引用Model refVisibilityInputContextMax outputNotescohere/command-a-plus-05-2026visibletext, image128,00064,000Default; flagship agentic and reasoning modelcohere/command-a-03-2025hiddentext256,0008,000Previous generation; replaced by Command Acohere/command-a-reasoning-08-2025hiddentext256,00032,000Previous generation; replaced by Command Acohere/command-a-vision-07-2025hiddentext, image128,0008,000Previous generation; replaced by Command Acohere/north-mini-code-1-0visibletext, image256,00064,000Agentic coding; reasoning; free limits从清单源码 extensions/cohere/openclaw.plugin.json 可以看到更多细节command-a-03-2025、command-a-reasoning-08-2025、command-a-vision-07-2025三个模型均标记为deprecated并被replacedBy指向command-a-plus-05-2026因此在目录中处于隐藏状态command-a-plus-05-2026与north-mini-code-1-0为当前可见型号。north-mini-code-1-0定位是 agentic coding 模型支持推理且标注了免费额度cost全为 0。推理模式映射off → none其余一律 high具备推理能力的 Cohere 模型支持 Compatibility API 的两种推理模式OpenClaw 将模型引用中的 thinking 级别映射为reasoning_effortoff 映射为none其余所有启用的思考级别minimal / low / medium / high / xhigh / adaptive / max一律映射为high。映射表定义在插件清单的compat.reasoningEffortMap字段extensions/cohere/openclaw.plugin.json测试用例在 extensions/cohere/index.test.ts 中验证了off → none与medium → high的转换行为覆盖了 Command A、Command A Reasoning 与 North Mini Code 三个推理模型。Command A Vision 的特殊处理禁用工具command-a-vision-07-2025明确不支持工具调用清单中compat.supportsTools: false。因此 OpenClaw 在为该模型保持 agent 工具禁用状态同时isModernModelRef判定extensions/cohere/models.ts将 Command A Vision 与 Command A旧版排除在现代模型集合之外避免现代 live sweeps 选中不具备工具能力的模型——因为现代模型扫描要求 agent 工具可用源码注释Modern sweeps require agent tool use。快速开始插件安装与 API Key 认证第一步安装官方插件并重启 Gatewayopenclaw plugins install openclaw/cohere-provider openclaw gateway restart插件声明在 extensions/cohere/openclaw.plugin.json 中activation.onStartup为false按需激活、enabledByDefault为true属于默认随 Gateway 加载的官方 provider 插件。第二步创建 Cohere API Key前往 Cohere 控制台创建 API Key密钥将通过环境变量COHERE_API_KEY提供给 Gateway。第三步运行 onboardingopenclaw onboard --non-interactive --accept-risk --skip-health \ --auth-choice cohere-api-key \ --cohere-api-key $COHERE_API_KEY其中--auth-choice cohere-api-key指定认证方式--cohere-api-key key是直接传入密钥的 CLI 标志。这两个标志均注册在插件清单的providerAuthChoices字段extensions/cohere/openclaw.plugin.json认证类型为api-key并带有appGuidedSecret: true标记表示应用可引导安全录入密钥。第四步验证目录可见openclaw models list --provider cohere该命令列出 Cohere 提供商的可见模型确认插件加载与目录注入成功。Onboarding 的模型设置规则有两个容易忽略的行为需要明确Onboarding 只在尚未配置任何主模型时才将 Cohere 设为主模型。源码 extensions/cohere/onboard.ts 通过createModelCatalogPresetAppliers生成预设测试 extensions/cohere/onboard.test.ts 验证当已有primary: openai/gpt-5.5时Cohere 不会覆盖主模型仅追加模型条目带Cohere Command A别名。Onboarding 会保留你已编写的模型条目并把生成的目录行交给 discovery模型发现处理。只有当配置为models.mode: replace时由于该模式跳过 discoveryonboarding 才会把内置目录完整写入配置extensions/cohere/onboard.tsundefined与merge模式下测试证实已编写的模型行原样保留extensions/cohere/onboard.test.ts。纯环境变量配置不跑 onboarding如果不想执行交互式 onboarding可以只把COHERE_API_KEY提供给 Gateway 进程然后在配置中选择 Cohere 模型{ agents: { defaults: { model: { primary: cohere/command-a-plus-05-2026 }, }, }, }注意如果 Gateway 以守护进程daemon或 Docker 方式运行必须在该服务本身设置COHERE_API_KEY。仅在交互式 shell 中导出环境变量不会让已运行的 Gateway 读到该密钥。配置中的primary引用格式为cohere/model-id对应插件清单defaultModel生成的默认引用cohere/command-a-plus-05-2026见 extensions/cohere/models.ts。底层原理请求流的两个关键适配Cohere 的 Compatibility API 与 OpenAI 协议存在两处差异OpenClaw 在请求流包装层wrapCohereProviderStreamextensions/cohere/stream.ts中做了适配角色改写system→developer。Cohere Compatibility API 使用developer角色承载指令而非system因此插件在发出请求前遍历messages把role system的消息改写为developer。测试 extensions/cohere/index.test.ts 明确断言最终载荷包含role: developer且不含role: system。删除tool_choice字段。Cohere 允许具备工具能力的模型在省略tool_choice时自行选择是否调用工具因此插件将该字段从载荷中移除把工具选择权完全交给模型。此外Compatibility API 使用max_tokens字段清单中compat.maxTokensField: max_tokens插件不会发送store、stream_options等 OpenAI 特有字段测试对此均有断言。实时模型发现strict 模式与 live discoveryCohere 插件将目录discoveryMode设为strict并注册了实时模型发现逻辑extensions/cohere/provider-catalog.ts发现端点https://api.cohere.com/v1/models?endpointchatpage_size1000校验条件请求返回必须包含models[]数组且只有baseUrl为https://api.cohere.ai/compatibility/v1时才允许发起发现requireBaseUrl防误配行归一化读取每条记录的name作为模型 idis_deprecated非真时标记active: true否则active: false。测试 extensions/cohere/index.test.ts 验证了该归一化逻辑command-fresh未废弃得到active: truecommand-retired废弃得到active: false。这意味着除了内置目录Gateway 还能在严格模式下从 Cohere 实时拉取新上线的 chat 端点模型保证新模型无需升级插件即可被发现。相关文档Model providers模型提供商总览Models CLI模型相关命令Provider directory提供商目录插件实现extensions/cohere/index.ts、extensions/cohere/onboard.ts、extensions/cohere/stream.ts、extensions/cohere/provider-catalog.ts测试用例extensions/cohere/index.test.ts、extensions/cohere/onboard.test.ts【免费下载链接】openclawThe AI that really does things. Any OS. Any Platform. The lobster way. 项目地址: https://gitcode.com/GitHub_Trending/cl/openclaw创作声明:本文部分内容由AI辅助生成(AIGC),仅供参考
返回列表