OpenClaw 使用指南
2026年最新中文手册 · 配置令牌与常见问题一站式解决方案
📋 目录
快速开始 配置与令牌设置 常用命令大全 10大常见问题解决 进阶配置示例
1. 快速开始
1.1 首次配置
运行交互式配置向导:
openclaw configure
分步骤配置:
# 配置模型
openclaw configure --section model
# 配置渠道
openclaw configure --section channels
# 配置 Gateway
openclaw configure --section gateway
1.2 启动服务
# 启动 Gateway
openclaw gateway start
# 或后台运行
openclaw daemon start
# 查看状态
openclaw status
1.3 打开控制台
openclaw dashboard
2. 配置与令牌设置
打开浏览器访问 OpenClaw 时需要输入令牌登录,有以下几种设置方法:
方法一:修改配置文件(推荐)📝
直接编辑配置文件 ~/.openclaw/openclaw.json:
{
"gateway": {
"auth": {
"mode": "token",
"token": "你的登录密码"
}
}
}
保存后重启 Gateway:
openclaw gateway restart
然后打开浏览器,输入设置的密码即可登录。
方法二:命令行设置
# 设置令牌
openclaw config set gateway.auth.token "你的登录密码"
# 重启生效
openclaw gateway restart
方法三:Control UI 管理
运行 openclaw dashboard 登录后可在线管理令牌。
2.1 配置文件位置
| 文件 | 说明 |
|---|---|
~/.openclaw/openclaw.json |
主配置文件 |
~/.openclaw/.env |
环境变量 |
~/.openclaw/workspace |
工作区目录 |
2.2 模型认证
Anthropic API 密钥:
# 方式1:环境变量
export ANTHROPIC_API_KEY="sk-ant-..."
# 方式2:写入 .env 文件
echo "ANTHROPIC_API_KEY=sk-ant-..." >> ~/.openclaw/.env
# 验证
openclaw models status
Claude 订阅 Token:
# 创建 token
claude setup-token
# 导入 OpenClaw
openclaw models auth setup-token --provider anthropic
3. 常用命令速查
Gateway 管理
| 命令 | 说明 |
|---|---|
openclaw gateway start |
启动 |
openclaw gateway stop |
停止 |
openclaw gateway restart |
重启 |
配置管理
| 命令 | 说明 |
|---|---|
openclaw config get <path> |
获取值 |
openclaw config set <path> <value> |
设置值 |
openclaw config validate |
验证配置 |
诊断工具
openclaw health # 健康检查
openclaw doctor # 医生诊断
openclaw doctor --fix # 自动修复
openclaw logs # 查看日志
4. 10大常见问题解决
Q1:配置文件不存在
问题:~/.openclaw/config.json 不存在
解决:运行配置向导
openclaw configure
Q2:令牌验证失败
问题:Gateway 拒绝启动,提示认证错误
解决:
# 检查配置
openclaw config get gateway
# 重新设置令牌
openclaw config set gateway.auth.token "正确的令牌"
# 重启
openclaw gateway restart
Q3:模型认证失败
问题:openclaw models status 显示错误
解决:
# 检查环境变量
echo $ANTHROPIC_API_KEY
# 检查 .env 文件
cat ~/.openclaw/.env
Q4:端口被占用
问题:端口 18799 被占用
解决:
# 查看占用
lsof -i :18799
# 修改端口
openclaw config set gateway.port 18800
openclaw gateway restart
Q5:渠道连接失败
问题:WhatsApp/Telegram/Discord 无法连接
解决:
# 检查配置
openclaw config get channels
# 运行诊断
openclaw doctor
# 重新配置
openclaw configure --section channels
Q6:工作区权限问题
问题:无法读写工作区文件
解决:
# 检查权限
ls -la ~/.openclaw/workspace
# 修复
chmod -R 755 ~/.openclaw/workspace
Q7:节点配对失败
问题:设备无法配对
解决:
# 查看状态
openclaw devices status
# 重新配对
openclaw devices pairing
Q8:Cron 任务不执行
问题:定时任务没触发
解决:
# 查看状态
openclaw cron status
# 列出任务
openclaw cron list
Q9:消息发送失败
问题:无法发送消息
解决:
# 检查连接
openclaw channels status
Q10:配置验证失败
问题:Schema 验证错误
解决:
# 查看错误
openclaw doctor
# 自动修复
openclaw doctor --fix
5. 进阶配置示例
多渠道配置
{
channels: {
whatsapp: {
allowFrom: ["+15555550123"],
groups: { "*": { requireMention: true } }
},
telegram: {
allowFrom: ["123456789"]
}
}
}
多智能体配置
{
agents: {
defaults: { workspace: "~/.openclaw/workspace" },
list: [
{ id: "main", name: "主智能体" },
{ id: "helper", name: "辅助智能体" }
]
}
}
安全设置
{
gateway: {
auth: { mode: "token", token: "your-token" },
controlUi: { allowedOrigins: ["https://yourdomain.com"] }
}
}
📚 资源链接
官方文档:https://docs.openclaw.ai[1] 中文文档:https://docs.openclaw.ai/zh-CN[2] 社区支持:https://discord.com/invite/clawd[3] 插件中心:https://clawhub.com[4]
如果你觉得有帮助,欢迎分享给更多需要的朋友!
往期精选:
[OpenClaw 安装与配置详解] [企业微信 MCP 工具使用指南] [搭建你的第一个 AI 助手]
引用链接
[1]https://docs.openclaw.ai
[2]https://docs.openclaw.ai/zh-CN
[3]https://discord.com/invite/clawd
[4]https://clawhub.com
夜雨聆风