第4章 · 免费预计阅读 1 分钟
基础配置
基础配置
OpenClaw 使用 ~/.openclaw/openclaw.json(JSON5)作为主配置文件。
首次向导
openclaw onboard --install-daemon
向导会自动完成:认证 Token、默认模型、可选消息渠道与守护进程安装。
最小可用配置
{
agents: {
defaults: {
model: {
primary: "anthropic/claude-sonnet-4-5",
},
workspace: "~/.openclaw/workspace",
},
},
}
在 ~/.openclaw/.env 中写入 API Key:
ANTHROPIC_API_KEY=sk-ant-api03-xxxxx
常用命令
# 查看配置
cat ~/.openclaw/openclaw.json
# 设置配置项
openclaw config set agents.defaults.model.primary "anthropic/claude-opus-4-6"
# 读取配置
openclaw config get
# 修改后重启
openclaw gateway restart
推荐结构示例
{
gateway: {
mode: "local",
port: 18789,
bind: "loopback",
auth: {
token: "${OPENCLAW_GATEWAY_TOKEN}",
},
},
agents: {
defaults: {
workspace: "~/.openclaw/workspace",
model: {
primary: "anthropic/claude-sonnet-4-5",
fallbacks: ["deepseek/deepseek-chat"],
},
thinkingDefault: "low",
timeoutSeconds: 600,
},
},
}
验证配置
openclaw doctor
openclaw status
openclaw dashboard
下一步
继续《消息渠道》配置 Telegram / Discord / WhatsApp 等渠道。
学完这章想实战?加入社群获得 $50 算力额度 + 实时答疑
加入社群 ¥99