首页 教程 分类 Skills下载 关于
ZH EN JA KO
基础配置

openclaw configure 配置向导教程

· 7 分钟

命令概述

openclaw configure 是 OpenClaw 的配置管理命令,支持交互式修改、导入导出和验证配置。

交互式配置

openclaw configure

启动交互式配置菜单:

OpenClaw Configuration
======================

What would you like to configure?
  [1] Providers (Model providers)
  [2] Models (Model settings)
  [3] Channels (Messaging channels)
  [4] Skills (AI skills and tools)
  [5] Security (Auth and access control)
  [6] Gateway (Server settings)
  [7] Logging (Log settings)
  [0] Exit

>

查看当前配置

# 显示完整配置(屏蔽敏感信息)
openclaw configure --show

# 显示特定部分
openclaw configure --show providers
openclaw configure --show channels
openclaw configure --show models

输出示例:

{
  "providers": {
    "openai": {
      "type": "openai",
      "baseUrl": "https://api.openai.com/v1",
      "apiKey": "sk-****...****",
      "models": ["gpt-4o", "gpt-4o-mini"]
    }
  }
}

直接设置配置项

无需进入交互模式,直接修改配置:

# 设置 Gateway 端口
openclaw configure set gateway.port 3001

# 设置模型温度
openclaw configure set models.main.temperature 0.8

# 设置频道系统提示词
openclaw configure set channels.telegram.systemPrompt "你是一个有用的助手"

读取配置项

openclaw configure get gateway.port
# 输出: 3000

openclaw configure get providers.openai.baseUrl
# 输出: https://api.openai.com/v1

验证配置

openclaw configure --validate

输出:

Validating configuration...
  ✓ JSON syntax: valid
  ✓ Required fields: present
  ✓ Provider references: valid
  ✓ Model references: valid
  ⚠ Warning: Channel "slack" references undefined model "slack-model"
  ✓ Security settings: valid

Validation result: 1 warning, 0 errors

导入导出

导出配置

# 导出完整配置(不含密钥值)
openclaw configure --export config-backup.json

# 导出含密钥的完整配置(加密)
openclaw configure --export config-full.enc --include-secrets

导入配置

# 从文件导入
openclaw configure --import config-backup.json

# 合并导入(保留本地已有配置)
openclaw configure --import config-backup.json --merge

配置差异对比

# 对比当前配置与文件
openclaw configure --diff config-old.json

输出:

- "gateway.port": 3000
+ "gateway.port": 3001

+ "providers.anthropic": { ... }

- "models.main.temperature": 0.7
+ "models.main.temperature": 0.8

重置配置

# 重置特定部分
openclaw configure --reset providers

# 重置全部配置为默认值
openclaw configure --reset-all

环境变量覆盖

配置文件中的值可以被环境变量覆盖:

# 覆盖端口
OPENCLAW_GATEWAY_PORT=3001 openclaw start

# 覆盖模型
OPENCLAW_DEFAULT_MODEL=gpt-4o-mini openclaw start

环境变量命名规则:OPENCLAW_ + 配置路径大写 + 用 _ 连接

配置文件格式

OpenClaw 支持 JSON 和 YAML 格式的配置文件:

# 使用 YAML 格式
openclaw configure --format yaml --export config.yaml

批量修改

使用 JSON Patch 进行批量修改:

openclaw configure --patch '[
  {"op": "replace", "path": "/gateway/port", "value": 3001},
  {"op": "add", "path": "/models/new-model", "value": {"provider": "openai", "model": "gpt-4o"}}
]'

配置历史

OpenClaw 保留配置修改历史:

# 查看修改历史
openclaw configure --history

# 回滚到之前的版本
openclaw configure --rollback 3

总结

openclaw configure 是管理 OpenClaw 配置的核心工具。无论是交互式修改还是脚本化批量操作,都能灵活应对。建议每次重要修改前先用 --export 备份,修改后用 --validate 验证。

OpenClaw 是开源免费的个人AI助手,支持 WhatsApp、Telegram、Discord 等多平台接入