基础配置
本指南介绍 OpenClaw 的核心配置选项。
配置文件位置
OpenClaw 的配置文件位于:
- macOS/Linux:
~/.openclaw/config.json - Windows:
%USERPROFILE%\.openclaw\config.json
配置命令
查看配置
bash
openclaw config list设置配置
bash
openclaw config set <key> <value>示例:
bash
openclaw config set model.provider anthropic
openclaw config set server.port 3000获取配置
bash
openclaw config get <key>重置配置
bash
openclaw config reset核心配置项
模型配置
json
{
"model": {
"provider": "anthropic",
"modelId": "claude-3-5-sonnet-20241022",
"apiKey": "your-api-key",
"baseUrl": "https://api.anthropic.com",
"temperature": 0.7,
"maxTokens": 4096
}
}支持的模型提供商
| 提供商 | provider 值 | 支持的模型 |
|---|---|---|
| Anthropic | anthropic | Claude 3.5 Sonnet, Claude 3 Opus |
| OpenAI | openai | GPT-4, GPT-4 Turbo, GPT-3.5 |
google | Gemini Pro, Gemini Ultra | |
| Kimi | kimi | Kimi-K2.5 |
| MiniMax | minimax | MiniMax-M2.5 |
| Ollama | ollama | Llama 3, Mistral, Qwen |
服务器配置
json
{
"server": {
"port": 3000,
"host": "localhost",
"https": {
"enabled": true,
"cert": "/path/to/cert.pem",
"key": "/path/to/key.pem"
}
}
}安全配置
json
{
"security": {
"mode": "sandbox",
"allowedPaths": [
"~/Documents",
"~/Projects"
],
"allowedCommands": [
"ls",
"cat",
"grep",
"git"
],
"blockedCommands": [
"rm -rf /",
"sudo"
],
"maxFileSize": 10485760,
"sessionTimeout": 3600
}
}安全模式
- sandbox: 沙盒模式,限制文件系统和命令执行
- full: 完全访问模式,允许完全访问系统资源
记忆配置
json
{
"memory": {
"enabled": true,
"storage": "local",
"maxEntries": 1000,
"retention": 2592000,
"embedding": {
"provider": "openai",
"model": "text-embedding-3-small"
}
}
}IM 平台配置
json
{
"im": {
"platforms": {
"telegram": {
"enabled": true,
"token": "your-bot-token",
"webhook": {
"enabled": true,
"url": "https://your-domain.com/webhook/telegram"
}
},
"discord": {
"enabled": true,
"token": "your-bot-token",
"clientId": "your-client-id"
},
"wechat_work": {
"enabled": true,
"corpId": "your-corp-id",
"agentId": "your-agent-id",
"secret": "your-secret"
}
}
}
}技能配置
json
{
"skills": {
"directory": "~/.openclaw/skills",
"autoUpdate": true,
"trustedAuthors": [
"openclaw",
"community-trusted"
],
"permissions": {
"network": true,
"filesystem": true,
"commands": true
}
}
}日志配置
json
{
"logging": {
"level": "info",
"format": "json",
"file": {
"enabled": true,
"path": "~/.openclaw/logs",
"maxSize": 10485760,
"maxFiles": 5
},
"console": {
"enabled": true,
"colorize": true
}
}
}环境变量
OpenClaw 支持通过环境变量配置:
bash
# 模型配置
export OPENCLAW_MODEL_PROVIDER=anthropic
export OPENCLAW_MODEL_API_KEY=your-api-key
# 服务器配置
export OPENCLAW_SERVER_PORT=3000
# 安全配置
export OPENCLAW_SECURITY_MODE=sandbox配置优先级
配置的优先级从高到低:
- 命令行参数
- 环境变量
- 配置文件
- 默认值
配置验证
使用 doctor 命令验证配置:
bash
openclaw doctor该命令会检查:
- 配置文件格式
- 必需配置项
- API 连接
- 权限设置