Skip to main content
skill CX Codex

openclaw-model-switch — Claude Code skill: how to install

Safely switches or repairs OpenClaw model settings in openclaw.json. It handles primary model switches, routing errors, and token hijack bugs without breaking gateway sync.

Install into Claude Code · Skills CLI (Vercel) All methods and platforms ↓
npx skills add daymade/claude-code-skills --skill openclaw-model-switch -a claude-code
Open on GitHub

What openclaw-model-switch does

The skill manages OpenClaw settings across candidate paths such as ~/.openclaw/openclaw.json and mirror directories under .kimi. It uses scripts/switch-model.py to create a backup in config-backups/, register model definitions, update agents.defaults.model.primary, and restart the gateway service.

Before modifying files, the workflow probes endpoints with direct curl requests to /v1/messages. This test catches key hijacking caused by environment variables like KIMI_API_KEY and identifies unavailable relay channels upfront. After restarting, it runs openclaw agent to confirm that the fallbackUsed flag is false.

Editing only one configuration file when mirror paths exist will cause OpenClaw to overwrite your changes during the next sync.

What it helps with

  • switch the primary agent model in openclaw.json
  • fix 401 Invalid token errors caused by environment key hijacking
  • resolve Thinking level conflicts across provider profiles
  • synchronize OpenClaw mirror configuration paths before restarting

Example prompts for the agent

  • Switch the primary OpenClaw model to k3 and restart the gateway
  • Probe the kimi-relay endpoint and fix the 503 No available channel error
  • Run switch-model.py for kimi-k2.7-code and verify fallbackUsed is false

How to install openclaw-model-switch

1Skills CLI (Vercel)

npx skills add daymade/claude-code-skills --skill openclaw-model-switch -a claude-code

2Manually: put the files in place

~/.claude/skills/openclaw-model-switch/SKILL.md

Copy the whole skill folder; for one project use .claude/skills/openclaw-model-switch/

Step by step, with commands for each platform: How to install skills in Claude Code: five ways

Questions about openclaw-model-switch

How do I install openclaw-model-switch in Claude Code?

Run npx skills add daymade/claude-code-skills --skill openclaw-model-switch -a claude-code.

What does openclaw-model-switch do?

It safely edits OpenClaw configuration files, updates primary models, backs up configurations, and resolves relay and key routing issues.

How does openclaw-model-switch verify a model change?

It runs an agent turn with openclaw agent --local --json and inspects the metadata. If fallbackUsed is true, the target model failed and a fallback handled the turn.

Source text

SKILL.md · MIT
---
name: openclaw-model-switch
description: >-
  Switches or repairs an OpenClaw instance's model config: changes the default model, adds model
  definitions, and fixes 401 "Invalid token", "No available channel / model not found", "Thinking
  level X is not supported", or a config edit that doesn't take effect. Use for 切换模型/换模型/升级模型 or
  模型配的错了. Not for plain config audits (use openclaw).
---

# 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"}]}'
```

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

```bash
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:

```bash
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, and `env` blocks — 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.

© daymade · MIT · daymade/claude-code-skills

Similar skills

All skills for Agent setup: memory, context, orchestration →

From the same set64

notify-wecom Sends a single one-off message to a WeCom (Enterprise WeChat) group bot. Handy when the team needs a quick ping without templates or setup. CX Codex +1 341installs setup-notifications-via-wecom Sets up a WeCom group bot webhook and sends technical status messages through it. Useful when a backup, sync or cron job should report on its own. CX Codex +1 341installs local-codex Runs the local OpenAI Codex CLI as a non-interactive sub-agent using ChatGPT OAuth. Ideal for offloading code generation and reviews without API keys. CX Codex +1 333installs wps-doc-scraper This skill archives public WPS/KDocs documents and embedded ProcessOn mind maps as raw data, SVG or PNG, and Markdown. Useful when a link has to be saved without logging in. CX Codex +1 334installs codex-image-gallery Launches a local browser gallery for reviewing Codex-generated images. Useful when you need to inspect local output folders without leaving your agent workflow. CX Codex +1 326installs download-gemini-images This skill downloads images from an open Gemini chat through your logged-in Chrome session and packages them into a ZIP in thread order. CX Codex +1 325installs claude-migrate-memory-to-doc Pulls your profile and preferences out of Claude's personal memory into documents that Claude, Cursor and other CLIs can read. CX Codex +1 325installs skill-governance Works out how many Skills the model actually sees, why the catalog is truncated, and which duplicates should go. Handy once your Skill list gets long. CX Codex +1 303installs

Project sponsors

Companies that keep this analytics open
Gold sponsor

Impressions, clicks and code copies — open statistics. We keep the numbers public for the same reason NeBlask itself is public. Become a sponsor