Configuration Reference
Tài liệu chi tiết về cấu hình Gateway.
File Location
OpenClaw tìm config file theo thứ tự:
--config <path>(nếu chạy CLI)~/.openclaw/openclaw.json5(RECOMMENDED - supports comments)~/.openclaw/openclaw.json
Schema Structure
{
// Gateway Settings
"gateway": {
"port": 18789,
"auth": {
"mode": "token" // or "password"
}
},
// Agent Definitions
"agents": {
"defaults": {
"model": "anthropic/claude-3-5-sonnet-20240620",
"sandbox": { "mode": "all" }
},
"list": [
{ "id": "main", "name": "Main Bot" },
{ "id": "dev", "name": "Dev Helper", "workspace": "~/dev-bot" }
],
// Routing Rules
"bindings": [
{ "agentId": "dev", "match": { "channel": "github" } }
]
},
// Channels Config
"channels": {
"telegram": {
"accounts": {
"bot1": { "token": "..." }
}
}
}
}
Config Includes ($include)
Với các setup phức tạp, bạn nên chia nhỏ file config.
openclaw.json5:
{
"gateway": { "port": 18789 },
"agents": { "$include": "./agents/agents.json5" },
"channels": { "$include": "./channels/telegram.json5" }
}
Merge Behavior:
$includestring: Thay thế toàn bộ object.$includearray: Merge lần lượt (file sau đè file trước).- Sibling keys: Đè lên giá trị từ include.
Environment Variables
Bạn có thể dùng biến môi trường trong config:
{
"channels": {
"telegram": {
"token": "${TELEGRAM_BOT_TOKEN}"
}
}
}
System Envs:
OPENCLAW_GATEWAY_TOKEN: Token auth mặc định.OPENCLAW_LOG_LEVEL: Đặt log level (debug,info,warn).PORT: Override gateway port.
Strict Validation
OpenClaw check config rất chặt chẽ khi khởi động.
- Nếu sai schema -> Exit với lỗi chi tiết.
- Không cho phép key thừa (tránh typo).
- Gợi ý sửa lỗi (Did you mean...?).
mẹo
Dùng openclaw doctor để validate config mà không cần restart services.