aw 完整教程!从安装到使用(官方脚本版)
📝 本教程基于 OpenClaw 官方文档和安装脚本编写,保证准确!
🤔 OpenClaw 是什么?
OpenClaw 是一个个人 AI 助手框架,让你可以在本地运行自己的 AI 助手。
它能帮你做什么?
✅ 聊天问答(微信、QQ、Telegram、Discord 等) ✅ 写文章、写代码 ✅ 定时提醒 ✅ 自动化任务 ✅ 浏览器操作 ✅ 文件处理
最大的好处:数据在自己电脑上,隐私安全!
🚀 一键安装(1 条命令)
打开命令行,复制粘贴以下命令:
curl -fsSL https://openclaw.ai/install.sh | bash
等待安装完成,过程大约 2-5 分钟。
⚙️ 配置向导详细流程
安装完成后,会自动进入配置向导 (openclaw onboard)。
第 1 步:欢迎界面
🦞 Welcome to OpenClaw!This wizard will help you set up your personal AI assistant.
按 Enter 继续。
第 2 步:选择 AI 模型
向导会显示可选的 AI 模型:
Select your AI provider: ○ OpenAI (GPT-4) ● Dashscope (通义千问) ← 推荐国内用户 ○ Anthropic (Claude) ○ Google (Gemini) ○ Skipfor now
操作方法:
用 ↑↓方向键选择按 Enter确认
模型推荐:
- 国内用户
:选 Dashscope(通义千问),速度快,便宜 - 有 OpenAI
:选 OpenAI,模型最强 - 有 Claude
:选 Anthropic,长文本厉害
第 3 步:填写 API Key
选择模型后,输入 API Key:
Enter your Dashscope API Key:> sk-____________________
如何获取 API Key?
通义千问(Dashscope):
访问:dashscope.console.aliyun.com/ 登录阿里云账号(没有就注册一个) 点击左侧"API Key 管理" 点击"创建新的 API Key" 复制生成的 Key(以 sk-开头)粘贴到向导里
OpenAI:
访问:platform.openai.com/ 登录或注册 点击左侧"API Keys" 点击"Create new secret key" 复制 Key(以 sk-proj-或sk-开头)
Claude(Anthropic):
访问:console.anthropic.com/ 登录或注册 点击"Get API keys" 点击"Create key" 复制 Key(以 sk-ant-开头)
第 4 步:测试连接
向导会测试 API Key 是否有效:
Testing connection to Dashscope...✅ Connection successful!Model: qwen-maxCredits remaining: ¥100.00
如果失败,会提示你重新输入。
第 5 步:选择连接平台
向导会问你要连接哪些聊天平台:
Select platforms toconnect: ○ WhatsApp ○ Telegram ○ Discord ○ Slack ○ WeChat (微信) ○ QQ ○ Skipfor now ← 新手建议先选这个
新手建议:
先选 Skip for now(跳过)等 OpenClaw 运行正常后再配置平台 配置平台需要额外的 Bot ID 或 Token
后续配置: 运行 openclaw channels add 可以添加平台
第 6 步:安装后台服务
向导会问是否安装后台服务(开机自启):
InstallGatewaydaemon?ThiswillstartOpenClawautomaticallyonboot.●Yes(recommended)○No
建议:
选 Yes:OpenClaw 会一直运行,随时可用选 No:每次需要手动运行openclaw gateway
后台服务类型:
- macOS
:launchd - Linux
:systemd - Windows
:WSL2 或手动运行
第 7 步:配置工作目录
向导会设置工作目录:
Workspacelocation:> /Users/你的用户名/.openclaw/workspaceChange location? (y/N)
建议:
直接按 Enter使用默认位置如果需要改,输入 y然后输入新路径
工作目录用途:
存放你的脚本 存放技能文件 存放记忆文件
第 8 步:完成配置
最后,向导会显示总结:
🎉Setupcomplete!Configuration summary:•AI Provider:Dashscope(qwen-max)•Workspace:~/.openclaw/workspace•Gateway:Running(port18789)•Channels:None(addlaterwith`openclawchannelsadd`)What'snext?•Chat:openclawagent--message"Hello"•Send message:openclawmessagesend--toxxx--message"Hi"•Add channel:openclawchannelsadd•View docs:openclawdocs
按 Enter 完成配置。
🎉 安装完成
配置完成后,你会看到:
🦞 OpenClaw installed successfully!✅ Gateway started on port 18789🤖 AI assistant ready
📚 使用教程
1. 和 AI 对话
最简单的方式:
openclaw agent --message "你好"
带思考等级:
# 快速回答openclaw agent --message "1+1 等于几" --thinking low# 深度思考openclaw agent --message "帮我写个 Python 脚本" --thinking high# 最高思考等级(最贵但最聪明)openclaw agent --message "分析这个项目的架构" --thinking ultra
连续对话:
openclaw agent# 进入交互模式,可以一直聊天# 输入 exit 退出
2. 发送消息
发送测试消息:
openclaw message send --message "Hello from OpenClaw"
发送到指定平台:
# Telegramopenclaw message send --to telegram:@username --message "Hi"# Discordopenclaw message send --to discord:channel_id --message "Hi"# 微信(需要配置)openclaw message send --to wechat:username --message "Hi"
3. WebUI 聊天(推荐新手)
OpenClaw 提供网页版聊天界面(Control UI),比命令行更直观!
方法 1:运行 dashboard 命令
openclaw dashboard
这会自动在浏览器打开控制面板。
方法 2:手动访问
确保网关已启动: openclaw gateway打开浏览器 访问:http://127.0.0.1:18789/
步骤 3:开始聊天
在网页中:
看到聊天界面 在输入框输入消息 按 Enter或点击发送AI 会立即回复
WebUI 功能:
✅ 实时对话(类似 ChatGPT 界面) ✅ 查看对话历史 ✅ 切换模型 ✅ 调整思考等级 ✅ 导出聊天记录
远程访问(从其他设备访问):
openclaw ui --host 0.0.0.0 --port 3000
然后在其他设备访问:http://服务器IP:3000
4. 管理技能(Skills)
查看已安装的技能:
openclaw skills list
安装新技能:openclaw skills install <技能名>
启用/禁用技能:openclaw skills enable <技能名>openclaw skills disable <技能名>
更新技能:openclaw skills update
4. 管理扩展(Extensions)
查看已安装的扩展:openclaw extensions list
安装扩展:openclaw extensions install <扩展名>
5. 管理通道(Channels)
查看已连接的通道:openclaw channels list
添加新通道:openclaw channels add# 跟着向导选择平台并配置
移除通道:openclaw channels remove <通道名>
🔧 调试和排错
1. 查看状态
查看整体状态:openclaw status
输出示例:OpenClaw Status===============Gateway: Running ✓Port: 18789Model: qwen-maxChannels: 0Skills: 5Uptime: 2h 30m
2. 查看日志
查看最近的日志:openclaw logs
实时查看日志:openclaw logs --follow# 按 Ctrl+C 退出
查看特定级别的日志:# 只看错误openclaw logs --level error# 只看警告openclaw logs --level warn# 详细模式openclaw logs --level debug
查看特定时间的日志:# 最近 1 小时openclaw logs --since 1h# 最近 100 行openclaw logs --tail 100
3. 运行医生检查
自动检查问题:openclaw doctor
输出示例:OpenClaw Doctor===============✓ Gateway is running✓ Configuration is valid✓ API key is valid✓ Network connection OK✓ Node.js version OK (v22.x.x)⚠ No channels configured (run: openclaw channels add)1 warning found.
非交互模式(适合脚本):openclaw doctor --non-interactive
4. 重启服务
重启网关:openclaw gateway restart
停止网关:openclaw gateway stop
启动网关:openclaw gateway start
5. 常见问题排查
问题 1:AI 不回复
检查步骤:
# 1. 检查网关状态openclaw status# 2. 检查 API Keyopenclaw doctor# 3. 查看日志openclaw logs --level error# 4. 测试连接openclaw agent --message "test"
问题 2:消息发送失败
检查步骤:
# 1. 检查通道配置openclaw channels list# 2. 检查通道状态openclaw channels status <通道名># 3. 查看通道日志openclaw logs --grep <通道名>
问题 3:技能不工作
检查步骤:
# 1. 查看已安装技能openclaw skills list# 2. 检查技能是否启用openclaw skills status <技能名># 3. 更新技能openclaw skills update <技能名># 4. 重新安装技能openclaw skills reinstall <技能名>
📋 完整命令参考
基础命令
openclaw status | openclaw status | |
openclaw doctor | openclaw doctor | |
openclaw logs | openclaw logs --follow | |
openclaw version | openclaw version | |
openclaw help | openclaw help |
网关命令
openclaw gateway | openclaw gateway --port 18789 | |
openclaw gateway start | openclaw gateway start | |
openclaw gateway stop | openclaw gateway stop | |
openclaw gateway restart | openclaw gateway restart |
AI 对话命令
openclaw agent | openclaw agent --message "你好" | |
openclaw chat | openclaw chat |
agent 命令参数:
--message "文本":发送的消息 --thinking low|medium|high|ultra:思考等级 --deliver <平台>:发送到指定平台
消息命令
openclaw message send | openclaw message send --to xxx --message "Hi" | |
openclaw message broadcast | openclaw message broadcast --message "通知" |
配置命令
openclaw onboard | openclaw onboard | |
openclaw config | openclaw config edit | |
openclaw config show | openclaw config show |
技能命令
openclaw skills list | openclaw skills list | |
openclaw skills install | openclaw skills install weather | |
openclaw skills enable | openclaw skills enable weather | |
openclaw skills disable | openclaw skills disable weather | |
openclaw skills update | openclaw skills update | |
openclaw skills uninstall | openclaw skills uninstall weather |
扩展命令
openclaw extensions list | openclaw extensions list | |
openclaw extensions install | openclaw extensions install qqbot | |
openclaw extensions update | openclaw extensions update |
通道命令
openclaw channels list | openclaw channels list | |
openclaw channels add | openclaw channels add | |
openclaw channels remove | openclaw channels remove telegram | |
openclaw channels status | openclaw channels status telegram |
更新命令
openclaw update | openclaw update | |
openclaw update --channel | openclaw update --channel beta |
版本通道:
stable:稳定版(推荐) beta:测试版 dev:开发版
📁 重要文件位置
~/.openclaw/openclaw.json | ||
~/.openclaw/logs/ | ||
~/.openclaw/workspace/ | ||
~/.openclaw/skills/ | ||
~/.openclaw/extensions/ | ||
~/.openclaw/memory/ |
快速打开配置文件夹:
Windows:explorer %USERPROFILE%\.openclaw
Mac:open ~/.openclaw
Linux:
cd ~/.openclaw
📚 更多文档
官方文档
- 入门指南
:docs.openclaw.ai/start/getti… - 配置向导
:docs.openclaw.ai/start/onboa… - 模型配置
:docs.openclaw.ai/concepts/mo… - 通道配置
:docs.openclaw.ai/channels/ov… - 技能开发
:docs.openclaw.ai/skills/crea… - 扩展开发
:docs.openclaw.ai/extensions/…
视频教程
- 官方 YouTube
:youtube.com/@openclaw - B 站搬运
:搜索 "OpenClaw"
社区资源
- Discord
:discord.gg/clawd(最活跃) - GitHub
:github.com/openclaw/op… - 技能市场
:clawhub.com
❓ 常见问题
1. 如何卸载?
# 1. 停止服务openclaw gateway stop# 2. 卸载 OpenClawnpm uninstall -g openclaw# 3. 删除配置(可选)rm -rf ~/.openclaw
2. 如何备份配置?
# 备份整个配置目录cp -r ~/.openclaw ~/.openclaw.backup# 或只备份配置文件cp ~/.openclaw/openclaw.json ~/backup/
3. 如何迁移到另一台电脑?
# 1. 在新电脑安装 OpenClawcurl -fsSL https://openclaw.ai/install.sh | bash# 2. 复制配置文件cp ~/.openclaw/openclaw.json 新电脑:~/.openclaw/# 3. 重启服务openclaw gateway restart
4. 如何查看 API 使用量?
# 通义千问openclaw usage# 或访问控制台# https://dashscope.console.aliyun.com/usage
5. 如何切换 AI 模型?
# 方法 1:重新运行配置向导openclaw onboard# 方法 2:手动编辑配置openclaw config edit# 修改 model.provider 和 model.apiKey
6. 如何在后台运行?
# macOS/Linuxopenclaw gateway --daemon# Windows(PowerShell)Start-Process openclaw gateway -WindowStyle Hidden
📝 总结
安装(1 条命令)
curl -fsSL https://openclaw.ai/install.sh | bash
配置(跟着向导走)
openclaw onboard # 安装后自动启动
使用(常用命令)
# 查看状态openclaw status# 和 AI 对话openclaw agent --message "你好"# 查看日志openclaw logs# 检查问题openclaw doctor
学习路径
✅ 安装完成 ✅ 运行 openclaw agent测试对话✅ 配置一个聊天通道(如 Telegram) ✅ 安装几个实用技能 ✅ 探索自动化功能
总耗时:15-30 分钟
开始使用吧! 💪
教程版本:v2.0(完整版)| 最后更新:2026-03-05
参考文档:docs.openclaw.ai
官方安装脚本:openclaw.ai/install.sh
社区:discord.gg/clawd
作者:南果梨链接:https://juejin.cn/post/7613590357511307302
夜雨聆风