配置详解
OpenClaw 的配置文件位于 ~/.openclaw/openclaw.json。本文档详细介绍所有配置选项。
配置文件位置
# macOS/Linux
~/.openclaw/openclaw.json
# Windows
%USERPROFILE%.openclawopenclaw.json基础配置示例
{
"gateway": {
"host": "127.0.0.1",
"port": 18789
},
"channels": {
"webchat": {
"enabled": true
},
"whatsapp": {
"enabled": false,
"allowFrom": ["+86138xxxxxxxx"]
}
},
"agent": {
"model": "anthropic/claude-3-5-sonnet-20241022"
}
}配置项说明
gateway(网关设置)
| 选项 | 类型 | 默认值 | 说明 |
|---|---|---|---|
host | string | 127.0.0.1 | 网关监听地址 |
port | number | 18789 | 网关监听端口 |
channels(频道设置)
WebChat
"webchat": {
"enabled": true,
"host": "127.0.0.1",
"port": 18789,
"basePath": "/"
}"whatsapp": {
"enabled": true,
"allowFrom": ["+86138xxxxxxxx"],
"groups": {
"*": {
"requireMention": true
}
}
}Telegram
"telegram": {
"enabled": true,
"botToken": "YOUR_BOT_TOKEN",
"allowFrom": ["your_telegram_id"],
"webhook": {
"enabled": false,
"url": "https://your-domain.com/webhook"
}
}Discord
"discord": {
"enabled": true,
"botToken": "YOUR_BOT_TOKEN",
"allowFrom": ["your_discord_id"]
}agent(Agent 设置)
"agent": {
"model": "anthropic/claude-3-5-sonnet-20241022",
"thinking": "low",
"reasoning": false,
"systemPrompt": "你是一个有帮助的 AI 助手。"
}| 选项 | 说明 |
|---|---|
model | 使用的 AI 模型,支持 anthropic/* 和 openai/* 格式 |
thinking | 思考级别:low、medium、high 或 off |
reasoning | 是否显示推理过程 |
systemPrompt | 系统提示词,定义 Agent 的行为 |
环境变量
以下环境变量可用于配置 API 密钥:
ANTHROPIC_API_KEY- Anthropic Claude API 密钥OPENAI_API_KEY- OpenAI API 密钥GEMINI_API_KEY- Google Gemini API 密钥DEEPSEEK_API_KEY- DeepSeek API 密钥
配置验证
使用以下命令验证配置是否正确:
openclaw gateway config:validate