Minimal Config (Just OpenAI)

The simplest possible configuration to get started with OpenAI:

# ~/.openclaw/config.yaml
provider: openai
model: gpt-4o
openai:
  api_key: "sk-proj-YOUR_KEY_HERE"

Developer Config

A comprehensive developer setup with multiple providers, verbose logging, and generous limits:

# ~/.openclaw/config.yaml — Developer Setup
provider: openai
model: gpt-4o
max_steps: 30
timeout: 600
log_level: debug

openai:
  api_key: "sk-proj-..."
  model: gpt-4o

claude:
  api_key: "sk-ant-..."
  model: claude-3-5-sonnet

ollama:
  base_url: http://localhost:11434
  model: llama3.2

profiles:
  fast:
    provider: ollama
    model: phi3
    max_steps: 10
  powerful:
    provider: claude
    model: claude-3-opus
    max_steps: 50

Privacy-First Config (Offline Only)

100% local operation — no data leaves your machine:

# Privacy-first: Ollama only, no cloud calls
provider: ollama
model: llama3.2
log_level: warn

ollama:
  base_url: http://localhost:11434
  model: llama3.2

# Block all cloud providers
allowed_providers:
  - ollama

# Restrict tools to local operations only
allowed_tools:
  - filesystem
  - git

Enterprise Config

Enterprise setup with proxy, audit logging, and restricted tool access:

# Enterprise configuration
provider: openai
model: gpt-4o
max_steps: 15
timeout: 120
log_level: info

openai:
  api_key: "${OPENCLAW_OPENAI_KEY}"  # loaded from secrets manager
  organization: "org-ENTERPRISE_ORG_ID"

# Corporate proxy
proxy:
  http: "http://proxy.corp.example.com:8080"
  https: "http://proxy.corp.example.com:8080"
  no_proxy: "localhost,127.0.0.1,.internal.example.com"

# Audit logging
audit:
  enabled: true
  log_path: "/var/log/openclaw/audit.jsonl"
  include_task: true
  include_output: false  # don't log potentially sensitive output

# Restrict to safe tools only
allowed_tools:
  - filesystem
  - git

Multi-Profile Setup

Switch between dev/staging/prod with the --profile flag or OPENCLAW_PROFILE env var:

# Multi-profile config.yaml
provider: ollama  # default (free)
model: llama3.2

profiles:
  dev:
    provider: ollama
    model: phi3
    log_level: debug
    max_steps: 10

  staging:
    provider: openai
    model: gpt-4o-mini
    max_steps: 20

  prod:
    provider: openai
    model: gpt-4o
    max_steps: 30
    timeout: 600
# Use profiles
openclaw run --profile dev "Quick test"
openclaw run --profile prod "Production analysis" --context ./data

Example 5: CI/CD Server Config

For automated pipelines — disables all interactive prompts, outputs machine-readable JSON:

# ~/.openclaw/config.yaml  (CI server)
provider: openai
model: gpt-4o-mini
max_tokens: 1024
timeout_seconds: 90
max_steps: 8
stream: false               # disable streaming — better for log parsing

# Non-interactive: never ask for confirmation
interactive: false
confirm_file_writes: false

# Output
output_format: json         # machine-parseable output
log_level: warning          # only log warnings/errors

# Safety guardrails
allow_command_exec: false   # no shell exec in CI
allowed_paths:
  - ./src/
  - ./tests/
  - ./output/

Example 6: High Security / Sandbox Config

# Maximum restriction config
provider: ollama             # fully local — no external API calls
model: llama3.2:8b
sandbox: true               # isolate file system access
allow_file_write: false     # read-only: agent can read but not modify files
allow_command_exec: false   # no shell commands
allow_network_fetch: false  # no web browse tool
allowed_paths:
  - /data/readonly/
max_steps: 5
max_tokens: 512

Per-Project Config Override

Drop an .openclaw.yaml in any project directory — it overrides your global config for that project only:

myproject/
├── .openclaw.yaml    ← project-specific overrides
├── src/
└── README.md
# myproject/.openclaw.yaml
model: gpt-4o            # use powerful model for this project
max_steps: 15
allowed_paths:
  - ./src/
  - ./tests/
# When you run from inside myproject/, the override is applied automatically
cd myproject
openclaw run "Refactor the auth module"

Validating Your Config

# Check for syntax errors and unknown keys
openclaw config validate

# Show the resolved config (merging all layers: global + project + env)
openclaw config dump

# Show where a specific key is coming from
openclaw config origin model

Validating Your Configuration

Always validate after editing config to catch YAML syntax errors before running tasks:

# Validate and show effective resolved config
openclaw config validate

# Validate a specific file
openclaw config validate --file ~/.openclaw/profiles/ci.yaml

# List all resolved key/value pairs (useful for debugging)
openclaw config list

# Example output from config validate:
# OK: provider = openai
# OK: model = gpt-4o-mini
# OK: max_steps = 25
# WARN: log_level = debug (not recommended in production)
# OK: memory.type = sqlite

Common Config Mistakes

MistakeErrorFix
Tabs instead of spacesYAML parse error: found character that cannot start any tokenUse spaces only in YAML; check editor settings
Unquoted special charactersmapping values are not allowed hereWrap values with : or # in quotes
Missing colonCFG_002: invalid YAML structureEvery key must be followed by : value
Wrong indentation levelNested key lands in wrong sectionUse 2-space indent; never mix levels

See the full reference at Environment Variables and Error Code Reference.