OpenClaw 的强大之处在于高度可配置性。本文详细介绍配置文件结构、模型接入、渠道配置等核心功能,帮助你打造专属的 AI 助手。
配置文件结构
~/.openclaw/
├── openclaw.json # 主配置文件
├── skills/ # 技能目录
├── memory/ # 记忆存储
├── workspace/ # 工作空间
└── logs/ # 日志文件
模型配置
OpenClaw 支持多种大语言模型,通过配置可以自由切换:
OpenAI 模型
"providers": {
"openai": {
"apiKey": "sk-xxx",
"baseUrl": "https://api.openai.com/v1",
"models": [
{"id": "gpt-4o", "name": "GPT-4o"},
{"id": "gpt-4o-mini", "name": "GPT-4o mini"}
]
}
}
Anthropic Claude 模型
"anthropic": {
"apiKey": "sk-ant-xxx",
"models": [
{"id": "claude-sonnet-4-6", "name": "Claude Sonnet 4.6"},
{"id": "claude-opus-4-5", "name": "Claude Opus 4.5"}
]
}
国产模型(百度、智谱、月之暗面等)
"providers": {
"baiduqianfancodingplan": {
"apiKey": "xxx",
"baseUrl": "https://qianfan..baidubce.com/v2",
"models": [
{"id": "qianfan-code-latest", "name": "ernie-code"}
]
}
}
渠道配置
OpenClaw 支持多种消息渠道同时接入:
Telegram 配置
"telegram": {
"botToken": "123456:ABC-DEF1234ghIkl-zyx57W2v1u123ew11",
"allowedUsers": ["user_id_1", "user_id_2"]
}
微信配置
"wechat": {
"corpId": "wwxxxx",
"corpSecret": "xxx",
"agentId": "1000001"
}
Discord 配置
"discord": {
"botToken": "xxx",
"guildId": "server_id",
"channelIds": ["channel_id_1"]
}
默认模型设置
"models": {
"default": "baiduqianfancodingplan/qianfan-code-latest",
"fallbacks": [
"openai/gpt-4o-mini",
"anthropic/claude-sonnet-4-6"
]
}
技能配置
OpenClaw 的技能系统是其核心特色:
"skills": {
"enabled": true,
"directory": "./skills",
"autoLoad": true
}
系统提示词定制
通过修改 SOUL.md 和 USER.md 定制 AI 的人格和知识:
- SOUL.md:定义 AI 的性格、说话方式
- USER.md:记录用户的偏好和习惯
- MEMORY.md:长期记忆存储
💡 提示:修改配置后需要重启服务:openclaw restart