2026-01-04 16:40:25 +01:00
---
2026-01-08 23:06:56 +01:00
summary: "Models CLI: list, set, aliases, fallbacks, scan, status"
2026-01-04 16:40:25 +01:00
read_when:
- Adding or modifying models CLI (models list/set/scan/aliases/fallbacks)
- Changing model fallback behavior or selection UX
- Updating model scan probes (tools/images)
2026-01-31 16:04:03 -05:00
title: "Models CLI"
2026-01-04 16:40:25 +01:00
---
2026-01-31 21:13:13 +09:00
2026-01-08 23:06:56 +01:00
# Models CLI
2026-01-04 16:40:25 +01:00
2026-01-08 23:06:56 +01:00
See [/concepts/model-failover ](/concepts/model-failover ) for auth profile
rotation, cooldowns, and how that interacts with fallbacks.
2026-01-10 21:37:38 +01:00
Quick provider overview + examples: [/concepts/model-providers ](/concepts/model-providers ).
2026-01-06 20:07:04 +00:00
2026-01-08 23:06:56 +01:00
## How model selection works
2026-01-07 18:20:02 +01:00
2026-01-30 03:15:10 +01:00
OpenClaw selects models in this order:
2026-01-07 18:20:02 +01:00
2026-01-31 21:13:13 +09:00
1. **Primary** model (`agents.defaults.model.primary` or `agents.defaults.model` ).
2. **Fallbacks** in `agents.defaults.model.fallbacks` (in order).
3. **Provider auth failover** happens inside a provider before moving to the
2026-01-08 23:06:56 +01:00
next model.
2026-01-07 18:20:02 +01:00
Related:
2026-01-31 21:13:13 +09:00
2026-01-30 03:15:10 +01:00
- `agents.defaults.models` is the allowlist/catalog of models OpenClaw can use (plus aliases).
2026-01-09 12:44:23 +00:00
- `agents.defaults.imageModel` is used **only when** the primary model can’ t accept images.
2026-01-12 06:00:00 +00:00
- Per-agent defaults can override `agents.defaults.model` via `agents.list[].model` plus bindings (see [/concepts/multi-agent ](/concepts/multi-agent )).
2026-01-07 18:20:02 +01:00
2026-01-10 17:36:50 +01:00
## Quick model picks (anecdotal)
- **GLM**: a bit better for coding/tool calling.
- **MiniMax**: better for writing and vibes.
## Setup wizard (recommended)
If you don’ t want to hand-edit config, run the onboarding wizard:
```bash
2026-01-30 03:15:10 +01:00
openclaw onboard
2026-01-10 17:36:50 +01:00
```
It can set up model + auth for common providers, including **OpenAI Code (Codex)
subscription** (OAuth) and **Anthropic** (API key recommended; `claude
setup-token` also supported).
2026-01-08 23:06:56 +01:00
## Config keys (overview)
2026-01-06 23:48:25 +01:00
2026-01-09 12:44:23 +00:00
- `agents.defaults.model.primary` and `agents.defaults.model.fallbacks`
- `agents.defaults.imageModel.primary` and `agents.defaults.imageModel.fallbacks`
- `agents.defaults.models` (allowlist + aliases + provider params)
2026-01-08 23:06:56 +01:00
- `models.providers` (custom providers written into `models.json` )
2026-01-08 08:50:04 +01:00
2026-01-08 23:06:56 +01:00
Model refs are normalized to lowercase. Provider aliases like `z.ai/*` normalize
to `zai/*` .
2026-01-07 02:52:28 +01:00
2026-01-10 01:26:03 +01:00
Provider configuration examples (including OpenCode Zen) live in
[/gateway/configuration ](/gateway/configuration#opencode-zen-multi-model-proxy ).
2026-01-09 01:59:22 +01:00
## “Model is not allowed” (and why replies stop)
2026-01-09 12:44:23 +00:00
If `agents.defaults.models` is set, it becomes the **allowlist** for `/model` and for
2026-01-09 01:59:22 +01:00
session overrides. When a user selects a model that isn’ t in that allowlist,
2026-01-30 03:15:10 +01:00
OpenClaw returns:
2026-01-09 01:59:22 +01:00
```
Model "provider/model" is not allowed. Use /model to list available models.
```
This happens **before** a normal reply is generated, so the message can feel
like it “didn’ t respond.” The fix is to either:
2026-01-09 12:44:23 +00:00
- Add the model to `agents.defaults.models` , or
- Clear the allowlist (remove `agents.defaults.models` ), or
2026-01-09 01:59:22 +01:00
- Pick a model from `/model list` .
Example allowlist config:
```json5
{
agent: {
model: { primary: "anthropic/claude-sonnet-4-5" },
models: {
"anthropic/claude-sonnet-4-5": { alias: "Sonnet" },
2026-02-05 16:54:44 -05:00
"anthropic/claude-opus-4-6": { alias: "Opus" },
2026-01-31 21:13:13 +09:00
},
},
2026-01-09 01:59:22 +01:00
}
```
2026-01-12 06:53:40 +00:00
## Switching models in chat (`/model`)
You can switch models for the current session without restarting:
```
/model
/model list
/model 3
/model openai/gpt-5.2
/model status
```
Notes:
2026-01-31 21:13:13 +09:00
2026-01-12 06:53:40 +00:00
- `/model` (and `/model list` ) is a compact, numbered picker (model family + available providers).
- `/model <#>` selects from that picker.
- `/model status` is the detailed view (auth candidates and, when configured, provider endpoint `baseUrl` + `api` mode).
2026-01-17 17:16:20 +00:00
- Model refs are parsed by splitting on the **first** `/` . Use `provider/model` when typing `/model <ref>` .
- If the model ID itself contains `/` (OpenRouter-style), you must include the provider prefix (example: `/model openrouter/moonshotai/kimi-k2` ).
2026-01-30 03:15:10 +01:00
- If you omit the provider, OpenClaw treats the input as an alias or a model for the **default provider** (only works when there is no `/` in the model ID).
2026-01-12 06:53:40 +00:00
Full command behavior/config: [Slash commands ](/tools/slash-commands ).
2026-01-08 23:06:56 +01:00
## CLI commands
2026-01-07 02:52:28 +01:00
2026-01-08 23:06:56 +01:00
```bash
2026-01-30 03:15:10 +01:00
openclaw models list
openclaw models status
openclaw models set < provider / model >
openclaw models set-image < provider / model >
openclaw models aliases list
openclaw models aliases add < alias > < provider / model >
openclaw models aliases remove < alias >
openclaw models fallbacks list
openclaw models fallbacks add < provider / model >
openclaw models fallbacks remove < provider / model >
openclaw models fallbacks clear
openclaw models image-fallbacks list
openclaw models image-fallbacks add < provider / model >
openclaw models image-fallbacks remove < provider / model >
openclaw models image-fallbacks clear
2026-01-08 23:06:56 +01:00
```
2026-01-07 02:52:28 +01:00
2026-01-30 03:15:10 +01:00
`openclaw models` (no subcommand) is a shortcut for `models status` .
2026-01-07 02:52:28 +01:00
2026-01-08 23:06:56 +01:00
### `models list`
2026-01-08 08:50:04 +01:00
2026-01-08 23:06:56 +01:00
Shows configured models by default. Useful flags:
2026-01-07 02:52:28 +01:00
2026-01-08 23:06:56 +01:00
- `--all` : full catalog
- `--local` : local providers only
- `--provider <name>` : filter by provider
- `--plain` : one model per line
- `--json` : machine‑ readable output
2026-01-04 16:40:25 +01:00
2026-01-08 23:06:56 +01:00
### `models status`
2026-01-07 18:23:07 +01:00
2026-01-08 23:06:56 +01:00
Shows the resolved primary model, fallbacks, image model, and an auth overview
2026-01-09 00:32:48 +00:00
of configured providers. It also surfaces OAuth expiry status for profiles found
in the auth store (warns within 24h by default). `--plain` prints only the
resolved primary model.
OAuth status is always shown (and included in `--json` output). If a configured
provider has no credentials, `models status` prints a **Missing auth** section.
JSON includes `auth.oauth` (warn window + profiles) and `auth.providers`
(effective auth per provider).
Use `--check` for automation (exit `1` when missing/expired, `2` when expiring).
2026-01-07 18:23:07 +01:00
2026-01-16 02:53:33 +00:00
Preferred Anthropic auth is the Claude Code CLI setup-token (run anywhere; paste on the gateway host if needed):
2026-01-09 15:29:50 +01:00
```bash
claude setup-token
2026-01-30 03:15:10 +01:00
openclaw models status
2026-01-09 15:29:50 +01:00
```
2026-01-08 23:06:56 +01:00
## Scanning (OpenRouter free models)
2026-01-07 18:23:07 +01:00
2026-01-30 03:15:10 +01:00
`openclaw models scan` inspects OpenRouter’ s **free model catalog** and can
2026-01-08 23:06:56 +01:00
optionally probe models for tool and image support.
2026-01-07 18:23:07 +01:00
2026-01-08 23:06:56 +01:00
Key flags:
2026-01-07 18:23:07 +01:00
2026-01-08 23:06:56 +01:00
- `--no-probe` : skip live probes (metadata only)
- `--min-params <b>` : minimum parameter size (billions)
- `--max-age-days <days>` : skip older models
- `--provider <name>` : provider prefix filter
- `--max-candidates <n>` : fallback list size
2026-01-09 12:44:23 +00:00
- `--set-default` : set `agents.defaults.model.primary` to the first selection
- `--set-image` : set `agents.defaults.imageModel.primary` to the first image selection
2026-01-04 16:40:25 +01:00
2026-01-08 23:06:56 +01:00
Probing requires an OpenRouter API key (from auth profiles or
`OPENROUTER_API_KEY` ). Without a key, use `--no-probe` to list candidates only.
2026-01-04 16:40:25 +01:00
2026-01-08 23:06:56 +01:00
Scan results are ranked by:
2026-01-31 21:13:13 +09:00
1. Image support
2. Tool latency
3. Context size
4. Parameter count
2026-01-04 16:40:25 +01:00
Input
2026-01-31 21:13:13 +09:00
2026-01-04 16:40:25 +01:00
- OpenRouter `/models` list (filter `:free` )
2026-02-07 15:40:35 -05:00
- Requires OpenRouter API key from auth profiles or `OPENROUTER_API_KEY` (see [/environment ](/help/environment ))
2026-01-04 16:40:25 +01:00
- Optional filters: `--max-age-days` , `--min-params` , `--provider` , `--max-candidates`
2026-01-04 17:50:55 +01:00
- Probe controls: `--timeout` , `--concurrency`
2026-01-04 16:40:25 +01:00
2026-01-08 23:06:56 +01:00
When run in a TTY, you can select fallbacks interactively. In non‑ interactive
mode, pass `--yes` to accept defaults.
## Models registry (`models.json`)
Custom providers in `models.providers` are written into `models.json` under the
2026-01-30 03:15:10 +01:00
agent directory (default `~/.openclaw/agents/<agentId>/models.json` ). This file
2026-01-08 23:06:56 +01:00
is merged by default unless `models.mode` is set to `replace` .