OpenClaw安装
考虑安全问题,建议使用非主力机电脑安装,或者直接使用大厂云服务器,
安装环境
Node 安装方式
- 安装node,参照官网
- 安装openclaw
npm install -g openclaw - 验证安装
openclaw --version
其他安装方式
- 官方脚本一键安装
macOS / Linux: curl -fsSL https://openclaw.ai/install.sh | bash Windows PowerShell: iwr -useb https://openclaw.ai/install.ps1 | iex - 源码安装
git clone https://github.com/openclaw/openclaw.git cd openclaw pnpm install pnpm build
初始化
通过上下左右方向键选择选项,按下回车确认, 多选用空格
-
运行交互式初始化向导
openclaw onboard -
◇ I understand this is personal-by-default and shared/multi-user use requires lock-down. Continue? │ Yes
-
◇ Onboarding mode │ QuickStart
-
◆ Model/auth provider │ ● Skip for now
-
◆ Filter models by provider │ ● All providers
-
◆ Default model │ ● Keep current (bailian/qwen-flash)
-
◆ Select channel (QuickStart)(通讯方式,后期使用QQ机器人) │ ● Skip for now (You can add channels later via
openclaw channels add) -
◆ Search provider │ ● Skip for now (Configure later with openclaw configure --section web)
-
◆ Configure skills now? (recommended) │ ● Yes / ○ No
-
◆ Install missing skill dependencies (知道的可以选,空格选中,后期可以修改) │ ◼ Skip for now (Continue without installing dependencies)
-
◆ Set GOOGLE_PLACES_API_KEY for goplaces? │ No
-
◆ Set GEMINI_API_KEY for nano-banana-pro? │ No
-
◆ Set NOTION_API_KEY for notion? │ No
-
◆ Set OPENAI_API_KEY for openai-image-gen? │ No
-
◆ Set OPENAI_API_KEY for openai-whisper-api? │ No
-
◆ Set ELEVENLABS_API_KEY for sag? │ No
-
◆ Enable hooks? (建议全选) │ ◻ Skip for now │ ◼ 🚀 boot-md (Run BOOT.md on gateway startup) │ ◼ 📎 bootstrap-extra-files (Inject additional workspace bootstrap │ files via glob/path patterns) │ ◼ 📝 command-logger (Log all command events to a centralized audit │ file) │ ◼ 💾 session-memory (Save session context to memory when /new or │ /reset command is issued)
-
◆ Gateway service installed
│ Control UI 信息
-
◆ How do you want to hatch your bot? │ ● Open the Web UI
-
安装安成
-
验证 浏览器访问 http://127.0.0.1:18789?token=xxxxxxx token 在 ~/.openclaw/openclaw.json 配置中查看,在gateway中
配置
添加QQBOT助手
申请 QQ 机器人 Token
1. 访问 https://q.qq.com/qqbot/openclaw/index.html
2. 登录你的 QQ 账号
3. 创建机器人并获取 Access Token
4. 复制 Token(格式类似 `xxxxxx:srrrsuwxxxxxxxxwBQg`)
安装 QQBot Channel 插件,命令行下
openclaw plugins install @sliverp/qqbot@latest
添加 QQ 通道
openclaw channels add --channel qqbot --token "YOUR_TOKEN_HERE"
重启 Gateway
openclaw gateway restart
测试连接
等待几秒后,打开你的 QQ,应该能看到新创建的机器人在好友列表中,发送消息即可交互。
配置模型
如果有付费会员,建议直接使用付费的。在初始化阶段就直接配置了就行,比较容易
前提
都说小龙虾是吃token大户,事实上测试下来也确实如此,幸好在此期间(20260310)
阿里云百炼平台除了新人免费额度,以下就依靠这个测试openclaw
虽然有点麻烦,但是总归是免费的,可以体验下openclaw到底是不是传说中的那么神
领取新人优惠
参考: help.aliyun.com/zh/model-st…
-
自行注册/登陆阿里云
-
进入「模型服务灵积」控制台
-
开通服务并获取 API Key
-
复制 Key(开头通常是
sk-...)
千万注意
批量先打开免费额度用完即停,一开始没注意到他消耗那么快。单模型100万额度一下子就没有了,是不知道,直接就扣钱了,等短信来了才知道,所以小白若非必要,可以先打开,后期根据需求再调整
配置小龙虾
编辑配置文件 ~/.openclaw/openclaw.json
添加 models 模块 和 修改 agents 配置
"models": {
"mode": "merge",
"providers": {
"bailian": {
"baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1",
"apiKey": "xxxxxxxxxxx",
"api": "openai-completions",
"models": [
{
"id": "qwen-flash",
"name": "qwen-flash",
"api": "openai-completions",
"reasoning": false,
"input": [
"text",
"image"
],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 1000000,
"maxTokens": 65536
}
]
}
}
},
"agents": {
"defaults": {
"model": {
"primary": "bailian/qwen-flash"
},
"models": {
"baishan/MiniMax-M2.5": {}
},
"workspace": "/xxx/.openclaw/workspace",
"compaction": {
"mode": "safeguard"
},
"maxConcurrent": 4,
"subagents": {
"maxConcurrent": 8
}
}
},
每次修改完 ~/.openclaw/openclaw.json文件,都要重启
openclaw gateway restart
配置局域网
默认openclaw都是使用本机访问的,但是电脑一般我们使用非主力机,所以老是切换也麻烦,所以修改成局域网访问
编辑配置文件 ~/.openclaw/openclaw.json
主要配置bind: loopback => lan 和 controlUi,没有则创建
"gateway": {
"port": 18789,
"mode": "local",
"bind": "lan",
"controlUi": {
"enabled": true,
"allowedOrigins": [
"http://内网地址:18789",
"http://localhost:18789",
"http://127.0.0.1:18789"
],
"allowInsecureAuth": false,
"dangerouslyDisableDeviceAuth": true
},
"auth": {
"mode": "token",
"token": "xxxxxxxxxxxxxx
"allowTailscale": false
},
"tailscale": {
"mode": "off",
"resetOnExit": false
},
...
openclaw gateway stop
临时绕过 CORS 限制(调试用)
openclaw gateway --allow-unconfigured
扩展ClawHub
文档地址:clawhub.ai/
聊天框直接让 openclaw 安装 clawhub
或者
openclaw skill install clawhub
并且安装指定的skill工作流
参考:zhuanlan.zhihu.com/p/201197229…
skill-vetter
tavily-search
find-skills
proactive-agent
github
gog
automation-workflows
self-improving-agent
summarize
常见问题
1. origin not allowed (open the Control UI from the gateway host or allow it in gateway.controlUi.allowedOrigins)
vim ~/.openclaw/openclaw.json
修改 gateway.controlUi.allowedOrigins
"gateway": {
...
"controlUi": {
"enabled": true,
"allowedOrigins": [
"http://内网地址:18789",
"http://localhost:18789",
"http://127.0.0.1:18789"
],
"allowInsecureAuth": false,
"dangerouslyDisableDeviceAuth": true
},
...
2. control ui requires device identity (use HTTPS or localhost secure context )
vim ~/.openclaw/openclaw.json
修改 gateway.controlUi 添加下面这两个参数,具体查看上题
"allowInsecureAuth": false,
"dangerouslyDisableDeviceAuth": true
3. device identity required
cat ~/.openclaw/openclaw.json
查看配置里面的token,并在链接上带上token值
http://xx.xx.xx.xx:18789/chat?session=main&token=xxxxxxx
4. Agent failed before reply: Model context window too small (4096 tokens). Minimum is 16000. Logs: openclaw logs --follow
vim ~/.openclaw/openclaw.json
修改 models添加下面这两个参数
"contextWindow": 16000,
"maxTokens": 16000
5. 400 status code (no body)
vim ~/.openclaw/openclaw.json
模型报错,参数等错误,主要修改models里面的参数问题
"models": {
"mode": "merge",
"providers": {
"bailian": {
"baseUrl": "https://dashscope.aliyuncs.com/compatible-mode/v1",
"apiKey": "xxxxxx",
"api": "openai-completions",
"models": [
{
"id": "qwen-flash",
"name": "qwen-flash",
"api": "openai-completions",
"reasoning": false,
"input": [
"text",
"image"
],
"cost": {
"input": 0,
"output": 0,
"cacheRead": 0,
"cacheWrite": 0
},
"contextWindow": 1000000,
"maxTokens": 65536
}
]
}
}
},
附录
常用命令速查
通常不需要手动操作,但以下命令在排查问题时可能用到:
========== 日常使用 ==========
openclaw chat # 进入交互式聊天
openclaw gateway start # 启动网关
openclaw gateway stop # 停止网关
openclaw gateway restart # 重启网关
openclaw gateway --force # 手动启动 Gateway(如果未自动启动)
openclaw logs --follow # 查看实时日志
openclaw daemon install/uninstall # 安装/卸载守护进程
========== 插件管理 ==========
openclaw plugins list # 查看所有已安装插件
openclaw plugins install <plugin-name> # 安装新插件
openclaw plugins update # 更新所有插件
========== 技能管理 ==========
openclaw skills list # 列出所有可用技能
openclaw skill install <skill-name> # 安装技能
openclaw skill update # 更新技能
========== 通道管理 ==========
openclaw channels list # 查看已配置通道
openclaw channels add --channel telegram # 添加 Telegram 等
openclaw channels remove <channel-id> # 删除通道
========== 定时任务 ==========
openclaw crons list # 查看所有计划任务
openclaw crons add "*/5 * * * *" # 添加定时任务
openclaw crons remove <cron-id> # 删除任务
========== 诊断排查 ==========
openclaw status # 查看运行状态
openclaw logs --since 1h # 查看最近 1 小时日志
openclaw healthcheck # 健康检查
卸载
第一种:推荐:使用内置卸载程序
openclaw uninstall
第二种:非交互式(自动化 / npx)
openclaw uninstall --all --yes --non-interactive
npx -y openclaw uninstall --all --yes --non-interactive
第三种:手动步骤
停止 Gateway 网关服务:
openclaw gateway stop
卸载 Gateway 网关服务(launchd/systemd/schtasks):
openclaw gateway uninstall
删除状态 + 配置:
rm -rf "${OPENCLAW_STATE_DIR:-$HOME/.openclaw}"
如果你将 OPENCLAW_CONFIG_PATH 设置为状态目录外的自定义位置,也请删除该文件。
删除你的工作区(可选,移除智能体文件):
rm -rf ~/.openclaw/workspace
移除 CLI 安装(选择你使用的那个):
npm rm -g openclaw
pnpm remove -g openclaw
bun remove -g openclaw
如果你安装了 macOS 应用:
rm -rf /Applications/OpenClaw.app