配置
OpenClaw 配置文件位于 ~/.openclaw/openclaw.json。
配置格式
使用 JSON5 格式(支持注释):
json5
{
// 网关配置
"gateway": {
"port": 18789,
"bind": "loopback",
"auth": {
"token": "your-secret-token"
}
},
// 智能体配置
"agents": {
"defaults": {
"model": {
"primary": "anthropic/claude-sonnet-4-20250514"
}
}
},
// 通道配置
"channels": {
"whatsapp": {
"enabled": true
}
}
}配置命令
bash
# 获取配置值
openclaw config get gateway.port
# 设置配置值
openclaw config set gateway.port 19000
# 删除配置值
openclaw config unset gateway.auth.password主要配置项
gateway
| 配置项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
| port | number | 18789 | 端口 |
| bind | string | loopback | 绑定模式 |
| auth.token | string | - | 认证 token |
| auth.password | string | - | 认证密码 |
agents.defaults
| 配置项 | 类型 | 说明 |
|---|---|---|
| model.primary | string | 主模型 |
| model.fallbacks | array | 故障转移模型 |
| workspace | string | 工作区路径 |
| timeoutSeconds | number | 超时时间 |
channels
各通道独立配置,参见通道文档。
环境变量
支持通过环境变量覆盖配置:
OPENCLAW_GATEWAY_PORTOPENCLAW_GATEWAY_TOKENOPENCLAW_CONFIG_PATHOPENCLAW_STATE_DIR
配置优先级
- 命令行参数
- 环境变量
- 配置文件
- 默认值