← Back to Skills Marketplace
ironmanc2014

Cn Api Router

by ironmanc2014 · GitHub ↗ · v1.1.0 · MIT-0
cross-platform ✓ Security Clean
175
Downloads
0
Stars
0
Active Installs
2
Versions
Install in OpenClaw
/install cn-api-router
Description
国内 AI 模型 API 配置向导。帮助 OpenClaw 用户快速配置 DeepSeek、通义千问、智谱GLM、 Moonshot(月之暗面)、百川、零一万物等国内大模型 API。 自动生成 OpenClaw 配置并通过 config.patch 安全写入,支持模型切换和多模型并存。 Use when: 用户说...
README (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,或换便宜模型
Usage Guidance
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.
Capability Analysis
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.
Capability Assessment
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.
How to Use
  1. Make sure OpenClaw is installed (local or Docker)
  2. Run the install command in chat: /install cn-api-router
  3. After installation, invoke the skill by name or use /cn-api-router
  4. Provide required inputs per the skill's parameter spec and get structured output
Version History
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 格式,可多模型并存,方便按需切换与成本优化。
Metadata
Slug cn-api-router
Version 1.1.0
License MIT-0
All-time Installs 0
Active Installs 0
Total Versions 2
Frequently Asked Questions

What is Cn Api Router?

国内 AI 模型 API 配置向导。帮助 OpenClaw 用户快速配置 DeepSeek、通义千问、智谱GLM、 Moonshot(月之暗面)、百川、零一万物等国内大模型 API。 自动生成 OpenClaw 配置并通过 config.patch 安全写入,支持模型切换和多模型并存。 Use when: 用户说... It is an AI Agent Skill for Claude Code / OpenClaw, with 175 downloads so far.

How do I install Cn Api Router?

Run "/install cn-api-router" in the OpenClaw or Claude Code chat to install it in one step — no extra setup required.

Is Cn Api Router free?

Yes, Cn Api Router is completely free, licensed under MIT-0. You can download, install and use it at no cost.

Which platforms does Cn Api Router support?

Cn Api Router is cross-platform and runs anywhere OpenClaw / Claude Code is available (cross-platform).

Who created Cn Api Router?

It is built and maintained by ironmanc2014 (@ironmanc2014); the current version is v1.1.0.

💬 Comments