Documentation Index
Fetch the complete documentation index at: https://docs.openclaw.ai/llms.txt
Use this file to discover all available pages before exploring further.
Model failover
Auth profile rotation, cooldowns, and how that interacts with fallbacks.
Model providers
Quick provider overview and examples.
Agent runtimes
PI, Codex, and other agent loop runtimes.
Configuration reference
Model config keys.
openai/gpt-5.5 can run through the normal OpenAI provider path or through the Codex app-server runtime, depending on agents.defaults.agentRuntime.id. See Agent runtimes.
How model selection works
OpenClaw selects models in this order:Related model surfaces
Related model surfaces
Selection source and fallback behavior
The sameprovider/model can mean different things depending on where it came from:
- Configured defaults (
agents.defaults.model.primaryand agent-specific primaries) are the normal starting point and useagents.defaults.model.fallbacks. - Auto fallback selections are temporary recovery state. They are stored with
modelOverrideSource: "auto"so later turns can keep using the fallback chain without probing a known-bad primary first. - User session selections are exact.
/model, the model picker,session_status(model=...), andsessions.patchstoremodelOverrideSource: "user"; if that selected provider/model is unreachable, OpenClaw fails visibly instead of falling through to another configured model. - Cron
--model/ payloadmodelis a per-job primary. It still uses configured fallbacks unless the job supplies explicit payloadfallbacks(usefallbacks: []for a strict cron run). - CLI default-model and allowlist pickers respect
models.mode: "replace"by listing explicitmodels.providers.*.modelsinstead of loading the full built-in catalog. - The Control UI model picker asks the Gateway for its configured model view:
agents.defaults.modelswhen present, otherwise explicitmodels.providers.*.models, otherwise the full catalog so fresh installs are not blank.
Quick model policy
- Set your primary to the strongest latest-generation model available to you.
- Use fallbacks for cost/latency-sensitive tasks and lower-stakes chat.
- For tool-enabled agents or untrusted inputs, avoid older/weaker model tiers.
Onboarding (recommended)
If you don’t want to hand-edit config, run onboarding:Config keys (overview)
agents.defaults.model.primaryandagents.defaults.model.fallbacksagents.defaults.imageModel.primaryandagents.defaults.imageModel.fallbacksagents.defaults.pdfModel.primaryandagents.defaults.pdfModel.fallbacksagents.defaults.imageGenerationModel.primaryandagents.defaults.imageGenerationModel.fallbacksagents.defaults.videoGenerationModel.primaryandagents.defaults.videoGenerationModel.fallbacksagents.defaults.models(allowlist + aliases + provider params)models.providers(custom providers written intomodels.json)
Model refs are normalized to lowercase. Provider aliases like
z.ai/* normalize to zai/*.Provider configuration examples (including OpenCode) live in OpenCode.Safe allowlist edits
Use additive writes when updatingagents.defaults.models by hand:
Clobber protection rules
Clobber protection rules
openclaw config set protects model/provider maps from accidental clobbers. A plain object assignment to agents.defaults.models, models.providers, or models.providers.<id>.models is rejected when it would remove existing entries. Use --merge for additive changes; use --replace only when the provided value should become the complete target value.Interactive provider setup and openclaw configure --section model also merge provider-scoped selections into the existing allowlist, so adding Codex, Ollama, or another provider does not drop unrelated model entries. Configure preserves an existing agents.defaults.model.primary when provider auth is re-applied. Explicit default-setting commands such as openclaw models auth login --provider <id> --set-default and openclaw models set <model> still replace agents.defaults.model.primary.”Model is not allowed” (and why replies stop)
Ifagents.defaults.models is set, it becomes the allowlist for /model and for session overrides. When a user selects a model that isn’t in that allowlist, OpenClaw returns:
ollama/gemma4:26b, lmstudio/Gemma4-26b-a4-it-gguf, or the
exact provider/model shown by openclaw models list --provider <provider>.
Bare local filenames or display names are not enough when the allowlist is
active.
Example allowlist config:
Switching models in chat (/model)
You can switch models for the current session without restarting:
Picker behavior
Picker behavior
/model(and/model list) is a compact, numbered picker (model family + available providers).- On Discord,
/modeland/modelsopen an interactive picker with provider and model dropdowns plus a Submit step. /models addis deprecated and now returns a deprecation message instead of registering models from chat./model <#>selects from that picker.
Persistence and live switching
Persistence and live switching
/modelpersists the new session selection immediately.- If the agent is idle, the next run uses the new model right away.
- If a run is already active, OpenClaw marks a live switch as pending and only restarts into the new model at a clean retry point.
- If tool activity or reply output has already started, the pending switch can stay queued until a later retry opportunity or the next user turn.
- A user-selected
/modelref is strict for that session: if the selected provider/model is unreachable, the reply fails visibly instead of silently answering fromagents.defaults.model.fallbacks. This is different from configured defaults and cron job primaries, which can still use fallback chains. /model statusis the detailed view (auth candidates and, when configured, provider endpointbaseUrl+apimode).
Ref parsing
Ref parsing
- Model refs are parsed by splitting on the first
/. Useprovider/modelwhen typing/model <ref>. - If the model ID itself contains
/(OpenRouter-style), you must include the provider prefix (example:/model openrouter/moonshotai/kimi-k2). - If you omit the provider, OpenClaw resolves the input in this order:
- alias match
- unique configured-provider match for that exact unprefixed model id
- deprecated fallback to the configured default provider — if that provider no longer exposes the configured default model, OpenClaw instead falls back to the first configured provider/model to avoid surfacing a stale removed-provider default.
CLI commands
openclaw models (no subcommand) is a shortcut for models status.
models list
Shows configured models by default. Useful flags:
Full catalog. Includes bundled provider-owned static catalog rows before auth is configured, so discovery-only views can show models that are unavailable until you add matching provider credentials.
Local providers only.
Filter by provider id, for example
moonshot. Display labels from interactive pickers are not accepted.One model per line.
Machine-readable output.
models status
Shows the resolved primary model, fallbacks, image model, and an auth overview 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.
Auth and probe behavior
Auth and probe behavior
- OAuth status is always shown (and included in
--jsonoutput). If a configured provider has no credentials,models statusprints a Missing auth section. - JSON includes
auth.oauth(warn window + profiles) andauth.providers(effective auth per provider, including env-backed credentials).auth.oauthis auth-store profile health only; env-only providers do not appear there. - Use
--checkfor automation (exit1when missing/expired,2when expiring). - Use
--probefor live auth checks; probe rows can come from auth profiles, env credentials, ormodels.json. - If explicit
auth.order.<provider>omits a stored profile, probe reportsexcluded_by_auth_orderinstead of trying it. If auth exists but no probeable model can be resolved for that provider, probe reportsstatus: no_model.
Auth choice is provider/account dependent. For always-on gateway hosts, API keys are usually the most predictable; Claude CLI reuse and existing Anthropic OAuth/token profiles are also supported.
Scanning (OpenRouter free models)
openclaw models scan inspects OpenRouter’s free model catalog and can optionally probe models for tool and image support.
Skip live probes (metadata only).
Minimum parameter size (billions).
Skip older models.
Provider prefix filter.
Fallback list size.
Set
agents.defaults.model.primary to the first selection.Set
agents.defaults.imageModel.primary to the first image selection.The OpenRouter
/models catalog is public, so metadata-only scans can list free candidates without a key. Probing and inference still require an OpenRouter API key (from auth profiles or OPENROUTER_API_KEY). If no key is available, openclaw models scan falls back to metadata-only output and leaves config unchanged. Use --no-probe to request metadata-only mode explicitly.- Image support
- Tool latency
- Context size
- Parameter count
- OpenRouter
/modelslist (filter:free) - Live probes require OpenRouter API key from auth profiles or
OPENROUTER_API_KEY(see Environment variables) - Optional filters:
--max-age-days,--min-params,--provider,--max-candidates - Request/probe controls:
--timeout,--concurrency
--yes to accept defaults. Metadata-only results are informational; --set-default and --set-image require live probes so OpenClaw does not configure an unusable keyless OpenRouter model.
Models registry (models.json)
Custom providers in models.providers are written into models.json under the agent directory (default ~/.openclaw/agents/<agentId>/agent/models.json). This file is merged by default unless models.mode is set to replace.
Merge mode precedence
Merge mode precedence
Merge mode precedence for matching provider IDs:
- Non-empty
baseUrlalready present in the agentmodels.jsonwins. - Non-empty
apiKeyin the agentmodels.jsonwins only when that provider is not SecretRef-managed in current config/auth-profile context. - SecretRef-managed provider
apiKeyvalues are refreshed from source markers (ENV_VAR_NAMEfor env refs,secretref-managedfor file/exec refs) instead of persisting resolved secrets. - SecretRef-managed provider header values are refreshed from source markers (
secretref-env:ENV_VAR_NAMEfor env refs,secretref-managedfor file/exec refs). - Empty or missing agent
apiKey/baseUrlfall back to configmodels.providers. - Other provider fields are refreshed from config and normalized catalog data.
Marker persistence is source-authoritative: OpenClaw writes markers from the active source config snapshot (pre-resolution), not from resolved runtime secret values. This applies whenever OpenClaw regenerates
models.json, including command-driven paths like openclaw agent.Related
- Agent runtimes — PI, Codex, and other agent loop runtimes
- Configuration reference — model config keys
- Image generation — image model configuration
- Model failover — fallback chains
- Model providers — provider routing and auth
- Music generation — music model configuration
- Video generation — video model configuration