基础配置

OpenClaw 使用 ~/.openclaw/openclaw.json(JSON5 格式)作为主配置文件。

配置向导

openclaw onboard --install-daemon

向导自动完成:认证 Token、默认模型、消息渠道与守护进程。

最小配置

{
  agents: {
    defaults: {
      model: {
        primary: "anthropic/claude-sonnet-4-5",
      },
      workspace: "~/.openclaw/workspace",
    },
  },
}

~/.openclaw/.env 中设置 API Key:

ANTHROPIC_API_KEY=sk-ant-api03-xxxxx

常用命令

# 查看配置
cat ~/.openclaw/openclaw.json

# 设置配置项
openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-6"

# 读取配置
openclaw config get

# 修改后重启
openclaw gateway restart

推荐配置模板

{
  gateway: {
    mode: "local",
    port: 18789,
    bind: "loopback",
    auth: {
      token: "${OPENCLAW_GATEWAY_TOKEN}",
    },
  },
  agents: {
    defaults: {
      workspace: "~/.openclaw/workspace",
      model: {
        primary: "anthropic/claude-sonnet-4-5",
        fallbacks: ["deepseek/deepseek-chat"],
      },
      thinkingDefault: "low",
      timeoutSeconds: 600,
    },
  },
}

验证配置

openclaw doctor
openclaw status
openclaw dashboard