← 返回 Skills 市场
ironmanc2014

Cn Api Router

作者 ironmanc2014 · GitHub ↗ · v1.1.0 · MIT-0
cross-platform ✓ 安全检测通过
175
总下载
0
收藏
0
当前安装
2
版本数
在 OpenClaw 中安装
/install cn-api-router
功能描述
国内 AI 模型 API 配置向导。帮助 OpenClaw 用户快速配置 DeepSeek、通义千问、智谱GLM、 Moonshot(月之暗面)、百川、零一万物等国内大模型 API。 自动生成 OpenClaw 配置并通过 config.patch 安全写入,支持模型切换和多模型并存。 Use when: 用户说...
使用说明 (SKILL.md)

CN API Router — 国内 AI 模型 API 配置向导

一键配置国内大模型 API 到 OpenClaw。不用翻文档,不用猜配置格式。

支持的模型

厂商 模型 价格参考(每百万 token) 特点
DeepSeek deepseek-chat, deepseek-reasoner ¥1-2 / ¥8-16 性价比之王
通义千问 qwen-turbo, qwen-plus, qwen-max ¥0.3-60 中文理解好
智谱 GLM glm-4-flash(免费), glm-4-plus ¥0-50 有免费模型
Moonshot moonshot-v1-8k/32k/128k ¥12-60 长上下文
百川 Baichuan3-Turbo, Baichuan4 ¥0.5-100 中文创作
零一万物 yi-medium, yi-large ¥0.5-20 性价比高

Quick Start

查看支持的厂商

python \x3Cskill-dir>/scripts/setup_model.py --list

生成配置

python \x3Cskill-dir>/scripts/setup_model.py --provider deepseek --api-key sk-xxx

交互式向导

python \x3Cskill-dir>/scripts/setup_model.py --interactive

Agent 配置写入流程

脚本只生成配置,实际写入由 Agent 通过 OpenClaw 内置工具完成,这是最安全的方式。

步骤

  1. 运行脚本获取 JSON 配置片段
  2. 使用 gateway config.patch 将 provider 合并到现有配置
  3. 重启生效

配置写入示例

Agent 拿到脚本输出后,执行:

gateway config.patch:
{
  "models": {
    "providers": {
      "deepseek": {
        "baseUrl": "https://api.deepseek.com/v1",
        "apiKey": "sk-xxx",
        "api": "openai-completions",
        "models": [
          {
            "id": "deepseek-chat",
            "name": "DeepSeek Chat",
            "reasoning": false,
            "input": ["text"],
            "contextWindow": 65536,
            "maxTokens": 8192
          }
        ]
      }
    }
  }
}

如果需要将某个 agent 切换到新模型:

gateway config.patch:
{
  "agents": {
    "defaults": {
      "model": {
        "primary": "deepseek/deepseek-chat"
      }
    }
  }
}

注意事项

  • config.patch 是安全的深度合并,不会覆盖其他 provider
  • API key 等敏感信息由 OpenClaw 加密存储
  • 写入后会自动重启 gateway

使用场景

场景 1:首次配置国内模型

  1. 引导用户获取 API key(附注册链接)
  2. 运行脚本生成配置(--provider xxx --api-key xxx
  3. config.patch 写入
  4. /model provider/model 验证

场景 2:添加备选模型

已有模型,想加备用:用脚本生成新 provider 配置,patch 追加即可。

场景 3:成本优化

用户说"API 太贵"时:

  1. 查看 references/providers.md 对比价格
  2. 推荐性价比方案
  3. 配置多模型,日常用便宜的,复杂任务切贵的

Provider 详情

references/providers.md 获取:

  • 每个厂商的完整模型列表和价格
  • OpenClaw JSON 配置格式(models.providers 结构)
  • 推荐组合方案(零成本 / 性价比 / 多模型)
  • API Key 注册地址和免费额度

故障排查

问题 原因 解决方案
401 Unauthorized API key 错误或过期 检查 key,到平台重新生成
429 Rate Limit 请求频率过高或余额不足 检查账户余额,降低频率
Connection timeout 网络问题 检查网络,部分厂商需实名认证
Model not found 模型名错误 对照 references/providers.md 检查
配置后不生效 需要重启 config.patch 会自动重启,或手动 /restart
输出质量差 模型选择不当 换更大的模型(如 qwen-max)
费用超预期 长对话 token 累积 启用 compaction,或换便宜模型
安全使用建议
This skill appears to do what it says: generate OpenClaw provider config JSON for various CN model vendors. Before using it: (1) inspect and run the included scripts locally (e.g., python scripts/setup_model.py --list) to confirm behavior; (2) use a test or limited API key first — the script prints the API key in the JSON, so avoid exposing production keys in logs or external telemetry; (3) verify your OpenClaw gateway's config.patch behavior and confirm it stores API keys encrypted as claimed; (4) do not paste API keys into untrusted UIs — prefer invoking the script locally and then applying the patch manually if you have concerns. If you need higher assurance, ask the author for a provenance/homepage or run the script in an isolated environment first.
功能分析
Type: OpenClaw Skill Name: cn-api-router Version: 1.1.0 The skill is a legitimate configuration utility designed to help users integrate Chinese AI model providers (such as DeepSeek, Qwen, and Zhipu GLM) into the OpenClaw platform. The Python script `scripts/setup_model.py` functions as a local configuration generator that produces JSON patches for the OpenClaw gateway without performing any network requests, file exfiltration, or unauthorized execution. The instructions in `SKILL.md` are well-scoped, guiding the AI agent to use the platform's intended `gateway config.patch` mechanism for updating settings.
能力评估
Purpose & Capability
Name/description, SKILL.md, providers.md, and the included Python script all align: they enumerate Chinese model providers and generate OpenClaw config.patch JSON containing a provider entry and an API key. No unrelated services, binaries, or secrets are requested.
Instruction Scope
SKILL.md correctly states the script only generates JSON and that the agent should use gateway config.patch to apply it. One operational risk: the script prints the API key in the generated JSON (it must, to populate the provider entry). That is expected for this purpose but means API keys appear in the script output — ensure the agent does not log, transmit, or expose that output to third parties before patching.
Install Mechanism
No install spec; only an instruction-only skill plus a small Python script included. No downloads, package installs, or archive extraction. Low install risk.
Credentials
The skill does not request environment variables, system config paths, or other credentials. It requires the user to supply an API key for the chosen provider (appropriate and proportional).
Persistence & Privilege
always: false and normal agent invocation. The skill suggests writing to OpenClaw config via gateway config.patch (appropriate for configuring models). It does not request persistent elevated privileges or modify other skills.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install cn-api-router
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /cn-api-router 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.1.0
cn-api-router 1.1.0 — 大幅更新配置流程,支持更安全的 agent 侧配置合并。 - 脚本现在只生成 provider JSON 配置片段,不再直接写入配置文件 - 建议通过 OpenClaw 的 `config.patch` 工具进行安全合并写入 - 更新支持模型表,精简并同步价格区间 - 优化使用流程说明,新增配置写入与场景操作分步指引 - references/providers.md 详细说明每个厂商配置及推荐方案
v1.0.0
Initial release: 国内 AI 模型 API 配置向导 for OpenClaw. - 支持 DeepSeek、通义千问、智谱GLM、Moonshot、百川、零一万物、MiniMax、阶跃星辰等主流国内大模型 API 配置和切换。 - 提供一键自动配置脚本与交互模式,简化 API 配置流程。 - 内附常见厂商注册/获取 API Key 指南及价格对比。 - 故障排查表帮助用户解决常见配置和使用问题。 - 兼容 OpenAI API 格式,可多模型并存,方便按需切换与成本优化。
元数据
Slug cn-api-router
版本 1.1.0
许可证 MIT-0
累计安装 0
当前安装数 0
历史版本数 2
常见问题

Cn Api Router 是什么?

国内 AI 模型 API 配置向导。帮助 OpenClaw 用户快速配置 DeepSeek、通义千问、智谱GLM、 Moonshot(月之暗面)、百川、零一万物等国内大模型 API。 自动生成 OpenClaw 配置并通过 config.patch 安全写入,支持模型切换和多模型并存。 Use when: 用户说... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 175 次。

如何安装 Cn Api Router?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install cn-api-router」即可一键安装,无需额外配置。

Cn Api Router 是免费的吗?

是的,Cn Api Router 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

Cn Api Router 支持哪些平台?

Cn Api Router 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 Cn Api Router?

由 ironmanc2014(@ironmanc2014)开发并维护,当前版本 v1.1.0。

💬 留言讨论