菜鸟AI - 让提示词生成更简单! 全站导航 全站导航
AI工具安装 新手教程 进阶教程 辅助资源 AI提示词 热点资讯 技术资讯 产业资讯 内容生成 模型技术 AI信息库

已有账号?

首页 > AI教程 > OpenClaw官方脚本版:从零开始安装使用教程
新手教程 从零开始

OpenClaw官方脚本版:从零开始安装使用教程

2026-06-03
阅读 0
热度 0
作者 菜鸟AI编辑部
摘要

摘要

先说说一个核心判断:如果你想在本地跑一个真正属于自己的AI助手,OpenClaw可能是个相当

先说说一个核心判断:如果你想在本地跑一个真正属于自己的AI助手,OpenClaw可能是个相当值得关注的选择。这份教程的内容完全基于官方文档和安装脚本编写,可以保证每一步都准确可靠。

OpenClaw从安装到使用的完整教程(官方脚本版)

OpenClaw 是什么?

说到OpenClaw,它本质上是一个个人AI助手框架——简单说,就是让你在自己的电脑上跑一个私人专属的AI。

它能帮你做什么?

  • ✅ 聊天问答(微信、QQ、Telegram、Discord等主流平台都能接)
  • ✅ 写文章、写代码
  • ✅ 定时提醒
  • ✅ 自动化任务
  • ✅ 操作浏览器
  • ✅ 处理文件

最大的好处就是数据全在自己电脑上,隐私和安全都有保障。

一键安装(1条命令)

装起来很简单,打开命令行,复制粘贴下面这条命令就行了:

curl -fsSL https://openclaw.ai/install.sh | bash

整个过程大概两到五分钟,等着完成就好。

配置向导详细流程

安装成功后,配置向导会自动启动(命令是 openclaw onboard)。下面把这个流程拆开来讲。

第1步:欢迎界面

? Welcome to OpenClaw!
This wizard will help you set up your personal AI assistant.

直接按 Enter 继续就行。

第2步:选择AI模型

接下来会看到可选模型的列表:

Select your AI provider:
  ○ OpenAI (GPT-4)
  ● Dashscope (通义千问)  ← 国内用户推荐
  ○ Anthropic (Claude)
  ○ Google (Gemini)
  ○ Skip for now

方向键选择,按 Enter 确认。

选哪个好?这里给个参考:

  • 国内用户:Dashscope(通义千问)最省心,速度快价格也低
  • 有OpenAI账号:选OpenAI,综合能力最强
  • 有Claude账号:选Anthropic,处理长文本很强大

第3步:填写API Key

选好模型后,需要填入你的API Key:

Enter your Dashscope API Key:
> sk-____________________

Key从哪里来?分几种情况:

通义千问(Dashscope):

  1. 访问 dashscope.console.aliyun.com
  2. 登录阿里云账号(没有就注册一个)
  3. 左侧点"API Key 管理"
  4. 点"创建新的 API Key"
  5. 复制生成的Key(以 sk- 开头)
  6. 粘贴到向导里

OpenAI:

  1. 访问 platform.openai.com
  2. 登录或注册
  3. 左侧点"API Keys"
  4. 点"Create new secret key"
  5. 复制Key(以 sk-proj-sk- 开头)

Claude(Anthropic):

  1. 访问 console.anthropic.com
  2. 登录或注册
  3. 点"Get API keys"
  4. 点"Create key"
  5. 复制Key(以 sk-ant- 开头)

第4步:测试连接

填完Key之后,向导会自动测试连通性:

Testing connection to Dashscope...
✅ Connection successful!
Model: qwen-max
Credits remaining: ¥100.00

万一连接失败,向导会提示你重新输入。

第5步:选择连接平台

向导会问你要不要连聊天平台:

Select platforms to connect:
  ○ WhatsApp
  ○ Telegram
  ○ Discord
  ○ Slack
  ○ WeChat (微信)
  ○ QQ
  ○ Skip for now  ← 新手建议先选这个

对新手有个建议:先选 Skip for now,等OpenClaw跑起来之后再配置平台。因为配置平台需要额外的Bot ID或Token,一上来就折腾这个容易劝退。

后面如果想加平台,运行 openclaw channels add 就行了。

第6步:安装后台服务

这一步问你要不要配置开机自启:

Install Gateway daemon?
This will start OpenClaw automatically on boot.

  ● Yes (recommended)
  ○ No

Yes 的话,OpenClaw会一直在后台运行,随时可以调用。选 No 的话,每次要用都得手动跑 openclaw gateway。建议一步到位选 Yes

不同系统的后台服务机制:

  • macOS:用的 launchd
  • Linux:用的 systemd
  • Windows:需要借助 WSL2 或手动管理

第7步:配置工作目录

向导会让你设置工作目录:

Workspace location:
> /Users/你的用户名/.openclaw/workspace
Change location? (y/N)

建议直接按 Enter,用默认位置最省事。如果想改,输 y 再填路径。

这个工作目录主要用来放:

  • 你自己的脚本
  • 技能文件
  • 记忆文件

第8步:完成配置

最后,向导会展示一个总结:

? Setup complete!
Configuration summary:
  • AI Provider: Dashscope (qwen-max)
  • Workspace: ~/.openclaw/workspace
  • Gateway: Running (port 18789)
  • Channels: None (add later with `openclaw channels add`)
What's next?
  • Chat: openclaw agent --message "Hello"
  • Send message: openclaw message send --to xxx --message "Hi"
  • Add channel: openclaw channels add
  • View docs: openclaw docs

确认无误后按 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"

发到指定平台:

# Telegram
openclaw message send --to telegram:@username --message "Hi"
# Discord
openclaw message send --to discord:channel_id --message "Hi"
# 微信(需要先配好)
openclaw message send --to wechat:username --message "Hi"

3. WebUI聊天(推荐新手)

OpenClaw自带网页版聊天界面(Control UI),比命令行直观得多。

方法1:运行 openclaw dashboard,会自动在浏览器打开控制面板。

方法2:手动访问——先确保网关已启动:openclaw gateway,然后打开浏览器访问 http://127.0.0.1:18789/

进去之后,看到聊天界面,在输入框输消息,按 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

5. 管理扩展(Extensions)

# 查看已装扩展
openclaw extensions list

# 安装扩展
openclaw extensions install <扩展名>

6. 管理通道(Channels)

# 查看已连的通道
openclaw channels list

# 添加新通道
openclaw channels add
# 跟着向导选平台配参数

# 移除通道
openclaw channels remove <通道名>

调试和排错

1. 查看状态

openclaw status

输出示例:

OpenClaw Status
===============
Gateway: Running ✓
Port: 18789
Model: qwen-max
Channels: 0
Skills: 5
Uptime: 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 Key
openclaw 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和AI对话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.jsonAI模型、平台配置
日志文件~/.openclaw/logs/运行日志
工作目录~/.openclaw/workspace/你的文件和脚本
技能目录~/.openclaw/skills/安装的技能
扩展目录~/.openclaw/extensions/安装的扩展
记忆文件~/.openclaw/memory/对话历史

各系统快速打开配置文件夹的方法:

Windows:explorer %USERPROFILE%\.openclaw

Mac:open ~/.openclaw

Linux:cd ~/.openclaw

常见问题

1. 如何卸载?

# 1. 停服务
openclaw gateway stop
# 2. 卸载
npm uninstall -g openclaw
# 3. 删配置(可选)
rm -rf ~/.openclaw

2. 如何备份配置?

# 备份整个目录
cp -r ~/.openclaw ~/.openclaw.backup
# 或只备份配置文件
cp ~/.openclaw/openclaw.json ~/backup/

3. 如何迁移到另一台电脑?

# 1. 新电脑先安装
curl -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/Linux
openclaw 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

学习路径建议:

  1. ✅ 装好
  2. ✅ 跑 openclaw agent 试一下对话
  3. ✅ 配置一个聊天通道(比如Telegram)
  4. ✅ 装几个实用技能
  5. ✅ 探索自动化功能

全部走下来,15到30分钟就能搞定。

来源:互联网

免责声明

本网站新闻资讯均来自公开渠道,力求准确但不保证绝对无误,内容观点仅代表作者本人,与本站无关。若涉及侵权,请联系我们处理。本站保留对声明的修改权,最终解释权归本站所有。

同类文章推荐

相关文章推荐

更多