openclaw config — Manage Configuration
View, set, and manage OpenClaw AI configuration settings from the CLI. Supports profiles, import/export, and environment variable overrides.
Synopsis
openclaw config <subcommand> [KEY] [VALUE]The config command is your primary interface for managing OpenClaw settings stored in ~/.openclaw/config.yaml. Changes take effect immediately for all subsequent openclaw run and openclaw start calls.
Subcommands
| Subcommand | Usage | Description |
|---|---|---|
get | config get KEY | Print the value of a specific config key |
set | config set KEY VALUE | Set a config key to a value |
list | config list | Print all current configuration keys and values |
reset | config reset [--confirm] | Reset all settings to factory defaults |
export | config export [FILE] | Export current config to a YAML file |
import | config import FILE | Import configuration from a YAML file |
Examples
Set Configuration Values
# Set OpenAI API key (stored securely in config)
openclaw config set openai.api_key "sk-proj-..."
# Switch provider to Anthropic Claude
openclaw config set provider claude
openclaw config set claude.api_key "sk-ant-..."
# Change default model
openclaw config set model claude-3-5-sonnet
# Set max steps globally
openclaw config set max_steps 30
# Set log level
openclaw config set log_level debugRead Configuration Values
# Get the current provider
openclaw config get provider
# Output: openai
# Check which model is configured
openclaw config get model
# Output: gpt-4o
# Get Ollama base URL (if configured)
openclaw config get ollama.base_url
# Output: http://localhost:11434List All Settings
openclaw config listprovider: openai
model: gpt-4o
max_steps: 20
timeout: 300
log_level: info
openai:
api_key: sk-proj-***redacted***
model: gpt-4o
claude:
api_key: (not set)
ollama:
base_url: http://localhost:11434
model: llama3.2Reset to Defaults
openclaw config reset --confirm
# All settings reset to defaults. API keys removed.Export and Import
# Export current config
openclaw config export ~/openclaw-backup.yaml
# Import on a new machine
openclaw config import ~/openclaw-backup.yamlConfig File Location
Configuration is stored in ~/.openclaw/config.yaml on all platforms:
| OS | Default Path |
|---|---|
| Linux / macOS | ~/.openclaw/config.yaml |
| Windows | %USERPROFILE%\.openclaw\config.yaml |
You can override this location with OPENCLAW_CONFIG_PATH:
export OPENCLAW_CONFIG_PATH=/etc/openclaw/config.yamlEnvironment Variable Overrides
Any config key can be overridden by an environment variable at runtime without modifying the config file. Environment variables take precedence over values in config.yaml:
# Override provider for a single session
OPENCLAW_PROVIDER=ollama openclaw run "Analyze this file" --context app.py
# PowerShell equivalent
$env:OPENCLAW_PROVIDER = "ollama"
openclaw run "Analyze this file" --context app.pyCLI flags > Environment variables > Config file values > Built-in defaults. This allows layered configuration for different environments.
- API Keys Setup — provider-specific key configuration
- Configuration Overview
- Environment Variables Reference
Config Profiles
Maintain separate profiles for different projects or environments. Switch instantly with a single command or environment variable:
# Create profiles by exporting different configs to named files
openclaw config set provider openai
openclaw config set openai.model gpt-4o
openclaw config export ~/.openclaw/profiles/work.yaml
openclaw config set provider ollama
openclaw config set model llama3.2
openclaw config export ~/.openclaw/profiles/personal.yaml
# Switch to work profile
openclaw config import ~/.openclaw/profiles/work.yaml
# Or override for a single command:
OPENCLAW_CONFIG_PATH=~/.openclaw/profiles/personal.yaml openclaw run "Draft a short email"Per-Project Config Override
Place a .openclaw.yaml file in a project directory to use project-specific settings automatically:
# .openclaw.yaml (project root)
provider: openai
openai:
model: gpt-4o
max_tokens: 2048
max_steps: 10
allowed_paths:
- ./src/
- ./tests/When you run openclaw from inside that directory, the local .openclaw.yaml overrides ~/.openclaw/config.yaml. Useful for enforcing per-project model choices or path restrictions.
Full Config Reference
# ~/.openclaw/config.yaml — all options with defaults shown
provider: openai # openai | claude | ollama | gemini
model: gpt-4o # default model for the provider
max_steps: 20 # max autonomous steps before pausing
timeout: 300 # request timeout in seconds
temperature: 0.7 # LLM temperature (0.0-2.0)
max_tokens: 4096 # max tokens per LLM response
log_level: info # debug | info | warn | error
log_file: "" # path to log file; empty = stderr only
dry_run: false # if true, plan but don't execute
allowed_tools: [] # empty = all tools allowed
openai:
api_key: "" # or set OPENAI_API_KEY env var
base_url: "" # custom endpoint (Azure, proxy)
claude:
api_key: "" # or set ANTHROPIC_API_KEY env var
ollama:
base_url: "http://localhost:11434"
model: llama3.2