Appearance
网关配置参考
OpenClaw 网关的主配置文件位于 ~/.openclaw/config.json。这是一个 JSON 格式的文件,包含了网关的所有配置选项。
配置文件结构
完整的配置文件结构示例:
json
{
"server": {
"port": 18789,
"bind": "0.0.0.0",
"baseUrl": "https://your-domain.com"
},
"ai": {
"model": "volcengine-plan/ark-code-latest",
"apiKey": "your-api-key-here",
"baseUrl": "https://ark.cn-beijing.volces.com/api/v3",
"maxTokens": 4096,
"temperature": 0.7
},
"channels": {
"feishu": {
"enabled": true,
"appId": "cli_xxxxxx",
"appSecret": "xxxxxx",
"allowFrom": ["ou_xxxxxx"],
"groups": {
"*": {
"requireMention": true
}
}
},
"telegram": {
"enabled": false,
"botToken": "xxxxxx:xxxxxx",
"allowFrom": []
}
},
"plugins": {
"exec": {
"enabled": true,
"allowElevated": false,
"allowedCommands": []
}
},
"credentials": {
"clawhub-api-key": "clh_xxxxxx"
},
"logging": {
"level": "info",
"file": "~/.openclaw/openclaw.log"
}
}配置项说明
server - 服务器配置
| 选项 | 类型 | 必填 | 说明 | 默认值 |
|---|---|---|---|---|
port | number | 否 | 网关监听端口 | 18789 |
bind | string | 否 | 绑定地址 | 0.0.0.0 |
baseUrl | string | 否 | 公网访问地址,用于 webhook 回调 | - |
TIP
baseUrl 不需要加端口,如果你使用反向代理(如 Nginx),直接填写域名即可。如果直接暴露端口,需要包含端口:https://your-domain:18789
ai - AI 模型配置
OpenClaw 支持多种 LLM 后端,当前主流使用火山引擎方舟平台:
| 选项 | 类型 | 必填 | 说明 | 默认值 |
|---|---|---|---|---|
model | string | 是 | 模型标识符 | - |
apiKey | string | 是 | API 密钥 | - |
baseUrl | string | 否 | API 基础地址 | 平台默认 |
maxTokens | number | 否 | 最大输出 tokens | 4096 |
temperature | number | 否 | 采样温度 0-2 | 0.7 |
常见模型标识符:
volcengine-plan/ark-code-latest- 火山方舟代码大模型volcengine/ep-20250xxx-xxxx/deepseek-v3- 自定义部署模型openai/gpt-4o- OpenAI GPT-4oanthropic/claude-3-5-sonnet- Anthropic Claude 3.5 Sonnet
channels - 通道配置
每个通道是一个键值对,键为通道名称:
json
"channels": {
"通道名称": {
"enabled": true,
"配置项": "值"
}
}通用配置项(所有通道都支持):
| 选项 | 类型 | 说明 |
|---|---|---|
enabled | boolean | 是否启用该通道 |
allowFrom | string[] | 允许访问的用户 ID 列表,留空允许所有 |
groups.requireMention | boolean | 群组中是否需要 @ 才触发 |
各通道的具体配置项请参考对应通道的文档:
plugins - 插件配置
OpenClaw 通过插件扩展功能,每个插件有自己的配置:
exec 插件 - 命令执行
json
"exec": {
"enabled": true,
"allowElevated": false,
"allowedCommands": [],
"workingDirectory": "~/.openclaw/workspace"
}| 选项 | 说明 |
|---|---|
enabled | 是否允许执行 shell 命令 |
allowElevated | 是否允许提权执行(sudo) |
allowedCommands | 允许执行的命令白名单,空数组允许所有 |
workingDirectory | 默认工作目录 |
credentials - 凭证存储
存放各种 API 密钥和凭证,技能会从这里读取:
json
"credentials": {
"clawhub-api-key": "clh_your-key-here",
"feishu-app-id": "cli_xxxxxx",
"other-api-key": "xxxxxx"
}ClawHub API 密钥默认会被自动读取,用于从技能市场安装技能。
logging - 日志配置
json
"logging": {
"level": "info",
"file": "~/.openclaw/openclaw.log"
}| 选项 | 说明 |
|---|---|
level | 日志级别:debug / info / warn / error |
file | 日志文件路径,不填输出到 stdout |
环境变量
部分配置可以通过环境变量覆盖,方便容器部署:
| 环境变量 | 对应配置项 |
|---|---|
OPENCLAW_PORT | server.port |
OPENCLAW_AI_MODEL | ai.model |
OPENCLAW_AI_API_KEY | ai.apiKey |
OPENCLAW_BASE_URL | server.baseUrl |
编辑配置
你可以直接用文本编辑器编辑配置文件:
bash
nano ~/.openclaw/config.json编辑完成后需要重启网关生效:
bash
# 如果使用 systemd 服务
sudo systemctl restart openclaw
# 如果前台运行
按 Ctrl+C 停止,然后重新启动验证配置
可以用以下命令验证配置文件格式是否正确:
bash
python3 -c "import json; json.load(open('$HOME/.openclaw/config.json')); print('✓ Config JSON syntax OK')"如果没有报错,说明格式正确。
配置示例
最小化配置(飞书 + 火山方舟)
json
{
"server": {
"port": 18789,
"baseUrl": "https://your-domain.com"
},
"ai": {
"model": "volcengine-plan/ark-code-latest",
"apiKey": "xxxxxxxxxxxxxxxx",
"baseUrl": "https://ark.cn-beijing.volces.com/api/v3"
},
"channels": {
"feishu": {
"enabled": true,
"appId": "cli_xxxxxxxx",
"appSecret": "xxxxxxxxxxxxxxxx",
"allowFrom": ["ou_xxxxxxxx"]
}
}
}多通道配置(飞书 + Telegram)
json
{
"server": {
"port": 18789,
"baseUrl": "https://your-domain.com"
},
"ai": {
"model": "volcengine-plan/ark-code-latest",
"apiKey": "xxxxxxxxxxxxxxxx"
},
"channels": {
"feishu": {
"enabled": true,
"appId": "cli_xxxxxxxx",
"appSecret": "xxxxxxxxxxxxxxxx",
"allowFrom": ["ou_xxxxxxxx"]
},
"telegram": {
"enabled": true,
"botToken": "123456:ABCDEF",
"allowFrom": [123456789]
}
}
}