openclaw-model-switch
- 作者仓库星标 0
- 作者更新于 2026年8月24日 15:33
- 作者仓库 claude-code-skills
OpenClaw Model Switch
Switch or repair an OpenClaw instance's model configuration by safely editing openclaw.json.
Diagnose before you edit. Model failures on OpenClaw are usually NOT the model id — they are key routing (env hijack), provider-plugin restrictions, or endpoint/model mismatch. Changing the model id without checking these first is how a 5-minute fix becomes a 2-hour debugging session. The full trap catalog with discovery commands lives in references/troubleshooting-model-config.md — read it the moment anything errors.
Step 1 — Find the real config file(s)
Do NOT assume a hardcoded path. Candidate locations (check all, edit all that exist):
~/.openclaw/openclaw.json— the gateway's live config on most installs~/.kimi/kimi-claw/openclaw.json— Kimi Claw mirror, kept in sync on some installs~/.kimi_openclaw/openclaw.json— legacy desktop path
Confirm which one the gateway actually reads: openclaw gateway status prints
Config (service): <path>. If several exist, treat them as mirrors: edit all of them
identically, otherwise the next sync overwrites your fix.
Step 2 — Probe the endpoint + model BEFORE touching config
Never trust a relay's model listing (GET /v1/models on new-api style relays is frequently
incomplete — a model can be absent from the list yet serve fine). The only authority is a
real completion probe from the host that will run the bot:
curl -sS -o /tmp/probe.json -w "HTTP %{http_code}\n" \
-X POST "<baseUrl>/v1/messages" \
-H "Authorization: Bearer <apiKey>" \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-d '{"model":"<model-id>","max_tokens":16,"messages":[{"role":"user","content":"hi"}]}'
Expected: HTTP 200 and a content array in the body. 401 Invalid token with a token you
just verified works elsewhere → the wire key is being hijacked (see trap #1 in the
troubleshooting reference). 503 No available channel → the model is not served for this
token/group from this network (trap #3) — pick a served model or fix the relay, don't
blind-switch.
Step 3 — Switch the model
python3 scripts/switch-model.py <model-id> --restart
# target a specific provider instead of the guessed one:
python3 scripts/switch-model.py k3 --provider kimi-relay --restart
# explicit config path (skips discovery):
python3 scripts/switch-model.py k3 --config ~/.openclaw/openclaw.json --restart
The script: discovers and backs up every candidate config to <config-dir>/config-backups/,
adds the model definition if known, sets agents.defaults.model.primary, syncs mirror
files, and restarts the gateway with --restart.
Step 4 — Verify end-to-end (mandatory)
A restarted gateway proves nothing. Run one real agent turn and read the result metadata:
openclaw agent --local --json --agent main --session-id verify-$(date +%s) -m "ping"
Success looks like: "result": "success", "fallbackUsed": false, and the gateway log shows
agent model: <provider>/<model> (thinking=...). "result": "success" with
fallbackUsed: true means your target failed and a fallback saved the turn — the config is
still wrong.
Common failures → read the troubleshooting reference
| Symptom | Most likely trap |
|---|---|
LLM error new_api_error: Invalid token, but the token works in curl |
Trap #1 — env KIMI_API_KEY hijacks the provider's wire key |
Thinking level "max" is not supported ... Use one of: off, on |
Trap #2 — kimi-provider plugin hardcodes binary thinking; bypass with a custom provider |
Thinking level ... Use one of: off, minimal, low, medium, high |
Trap #2 variant — anthropic-messages base profile; unlock via params.canonicalModelId |
503 No available channel for model X under group default |
Trap #3 — model not served for this group/network; listing ≠ availability |
| Edit saved + gateway restarted, nothing changed | Trap #5 — edited the wrong file / mirror not synced |
Safety rules
- Always backup before editing (the script does this; manual edits: copy to
config-backups/first) - Preserve existing
apiKey,headers, plugin configs, andenvblocks — retype only the fields you mean to change - Validate JSON after manual edits:
python3 -m json.tool openclaw.json > /dev/null - Do not commit config files containing API keys to version control
- After changing anything, redo the Step-4 verification — and if it fails, restore the newest backup before trying something else
Resources
- scripts/switch-model.py — model switcher with config discovery, backup, mirror sync, and restart
- references/kimi-models.md — known model specs (k3, k2p6, kimi-k2.7-code) and config snippets
- references/troubleshooting-model-config.md — the trap catalog: env key hijack, plugin binary thinking, canonicalModelId, relay availability, config discovery. Read on any error.
- 流狐分类
- 通用
- 作者声明 Agent
- 未找到明确声明;不据此推断已兼容或已测试
- 静态检查
- 88 / 100 · 启发式扫描,不代表运行安全
- 作者 / 版本 / 许可
- @daymade · 未声明 license
- 流狐 Token 估算
- 低消耗
- 流狐接入估算
- 需简单配置
- 是否需要外部 API Key
- 需要 · Vendor-specific
- 检测到的系统要求
- 未声明
- 底层运行要求
- 未声明
- 检测到的文件与系统行为
-
- 只读
- 允许写入 / 修改
- 检测到的网络行为
- 允许外网请求
- 安装命令数
- 无(仅作为资料)
档案由构建时根据 SKILL.md 与安装命令自动衍生,可能与作者实际意图存在差异。
需要注意: 未限定 allowed-tools,默认拥有全部工具权限。
作者没有在当前 SKILL.md 中定义固定输出样例。 Do NOT assume a hardcoded path. Candidate locations (check all, edit all that exist): ~/.openclaw/openclaw.json — the gateway's live config on most installs ~/.kimi/kimi-claw/openclaw.json — Kimi Claw mirror, kept in sync on some installs
Never trust a relay's model listing (GET /v1/models on new-api style relays is frequently incomplete — a model can be absent from the list yet serve fine). The only authority is a real completion probe from the host that will run the bot:
The script: discovers and backs up every candidate config to <config-dir>/config-backups/, adds the model definition if known, sets agents.defaults.model.primary, syncs mirror files, and restarts the gateway with --restart.
A restarted gateway proves nothing. Run one real agent turn and read the result metadata: Success looks like: "result": "success", "fallbackUsed": false, and the gateway log shows agent model: <provider>/<model> (thinking=...). "result": "success" with
# OpenClaw Model Switch
Switch or repair an OpenClaw instance's model configuration by safely editing `openclaw.json`.
**Diagnose before you edit.** Model failures on OpenClaw are usually NOT the model id —
they are key routing (env hijack), provider-plugin restrictions, or endpoint/model mismatch.
Changing the model id without checking these first is how a 5-minute fix becomes a 2-hour
debugging session. The full trap catalog with discovery commands lives in
[references/troubleshooting-model-config.md](references/troubleshooting-model-config.md) — read it
the moment anything errors.
## Step 1 — Find the real config file(s)
Do NOT assume a hardcoded path. Candidate locations (check all, edit all that exist):
1. `~/.openclaw/openclaw.json` — the gateway's live config on most installs
2. `~/.kimi/kimi-claw/openclaw.json` — Kimi Claw mirror, kept in sync on some installs
3. `~/.kimi_openclaw/openclaw.json` — legacy desktop path
Confirm which one the gateway actually reads: `openclaw gateway status` prints
`Config (service): <path>`. If several exist, treat them as mirrors: **edit all of them
identically**, otherwise the next sync overwrites your fix.
## Step 2 — Probe the endpoint + model BEFORE touching config
Never trust a relay's model listing (`GET /v1/models` on new-api style relays is frequently
incomplete — a model can be absent from the list yet serve fine). The only authority is a
real completion probe **from the host that will run the bot**:
```bash
curl -sS -o /tmp/probe.json -w "HTTP %{http_code}\n" \
-X POST "<baseUrl>/v1/messages" \
-H "Authorization: Bearer <apiKey>" \
-H "Content-Type: application/json" \
-H "anthropic-version: 2023-06-01" \
-d '{"model":"<model-id>","max_tokens":16,"messages":[{"role":"user","content":"hi"}]}'
```
… 作者原文负责流程事实;流狐只索引当前章节、要点、文件与命令。
章节 -> Step 1 — Find the real config file(s) → Step 2 — Probe the endpoint + model BEFORE touching config → Step 3 — Switch the model → Step 4 — Verify end-to-end (mandatory) → Common failures → read the troubleshooting reference → Safety rules
要点 -> Diagnose before you edit. · from the host that will run the bot · from this network · Always backup · Preserve · Validate JSON · Do not · scripts/switch-model.py
文件/命令 -> openclaw.json · ~/.openclaw/openclaw.json · ~/.kimi/kimi-claw/openclaw.json · ~/.kimiopenclaw/openclaw.json · openclaw gateway status · Config (service): <path> · GET /v1/models · HTTP 200
内容 SHA-256 -> 6a300348ee27
方法与流程
适用与边界
原文中的明确线索
openclaw.json、~/.openclaw/openclaw.json、~/.kimi/kimi-claw/openclaw.json、~/.kimiopenclaw/openclaw.json、openclaw gateway status、Config (service): <path>、GET /v1/models、HTTP 200