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

Written by

in

文章目录
  • OpenClaw 是一个个人 AI 助手框架,让你可以在本地运行自己的 AI 助手。 它能帮你做什么? ✅ 聊天问答(微信、QQ、Telegram、Discord 等) ✅ 写文章、写代码 ✅ 定时提醒 ✅ 自动化任务 ✅ 浏览器操作 ✅ 文件处理 最大的好处:数据在自己电脑上,隐私安全!
  • 打开命令行,复制粘贴以下命令: curl -fsSL https://openclaw.ai/install.sh | bash 等待安装完成,过程大约 2-5 分钟。
  • 安装完成后,会自动进入配置向导 (openclaw onboard)。
  • 配置完成后,你会看到: 🦞 OpenClaw installed successfully! ✅ Gateway started on port 18789 🤖 AI assistant ready
  • 内容 位置 说明 配置文件 ~/.openclaw/openclaw.json AI 模型、平台配置 日志文件 ~/.openclaw/logs/ 运行日志 工作目录 ~/.openclaw/workspace/ 你的文件和脚本 技能目录 ~/.openclaw/skills/ 安装的技能 扩展目录 ~/.openclaw/extensions/ 安装的扩展 记忆文件 ~/.openclaw/memory/ 对话历史 快速打开配置文件夹: Windows: explorer %USERPROFILE%.openclaw Mac: open ~/.openclaw Linux: cd ~/.openclaw
  • 目录
    • OpenClaw 是什么?
    • 一键安装(1 条命令)
    • 配置向导详细流程
      • 第 1 步:欢迎界面
      • 第 2 步:选择 AI 模型
      • 第 3 步:填写 API Key
      • 第 4 步:测试连接
      • 第 5 步:选择连接平台
      • 第 6 步:安装后台服务
      • 第 7 步:配置工作目录
      • 第 8 步:完成配置
    • 安装完成
      • 使用教程
      • 1. 和 AI 对话
      • 2. 发送消息
      • 3. WebUI 聊天(推荐新手)
      • 4. 管理技能(Skills)
      • 4. 管理扩展(Extensions)
      • 5. 管理通道(Channels)
    • 调试和排错
      • 1. 查看状态
      • 2. 查看日志
      • 3. 运行医生检查
      • 4. 重启服务
      • 5. 常见问题排查
    • 完整命令参考
      • 基础命令
      • 网关命令
      • AI 对话命令
      • 消息命令
      • 配置命令
      • 技能命令
      • 扩展命令
      • 通道命令
      • 更新命令
    • 重要文件位置
      • 常见问题
        • 1. 如何卸载?
        • 2. 如何备份配置?
        • 3. 如何迁移到另一台电脑?
        • 4. 如何查看 API 使用量?
        • 5. 如何切换 AI 模型?
        • 6. 如何在后台运行?
      • 总结
        • 安装(1 条命令)
        • 配置(跟着向导走)
        • 使用(常用命令)
        • 学习路径

      本教程基于 OpenClaw 官方文档和安装脚本编写,保证准确!

      OpenClaw 是一个个人 AI 助手框架,让你可以在本地运行自己的 AI 助手。

      它能帮你做什么?

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

      最大的好处:数据在自己电脑上,隐私安全!

      打开命令行,复制粘贴以下命令:

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

      等待安装完成,过程大约 2-5 分钟。

      安装完成后,会自动进入配置向导 (openclaw onboard)。

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

      Enter 继续。

      向导会显示可选的 AI 模型:

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

      操作方法

      • 方向键选择
      • Enter 确认

      模型推荐

      • 国内用户:选 Dashscope(通义千问),速度快,便宜
      • 有 OpenAI:选 OpenAI,模型最强
      • 有 Claude:选 Anthropic,长文本厉害

      选择模型后,输入 API Key:

      Enter your Dashscope API Key:
      > sk-____________________

      如何获取 API 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- 开头)

      向导会测试 API Key 是否有效:

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

      如果失败,会提示你重新输入。

      向导会问你要连接哪些聊天平台:

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

      新手建议

      • 先选 Skip for now(跳过)
      • 等 OpenClaw 运行正常后再配置平台
      • 配置平台需要额外的 Bot ID 或 Token

      后续配置: 运行 openclaw channels add 可以添加平台

      向导会问是否安装后台服务(开机自启):

      Install Gateway daemon?
      This will start OpenClaw automatically on boot.
      
        ● Yes (recommended)
        ○ No
      

      建议

      • Yes:OpenClaw 会一直运行,随时可用
      • No:每次需要手动运行 openclaw gateway

      后台服务类型

      • macOS:launchd
      • Linux:systemd
      • Windows:WSL2 或手动运行

      向导会设置工作目录:

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

      建议

      • 直接按 Enter 使用默认位置
      • 如果需要改,输入 y 然后输入新路径

      工作目录用途

      • 存放你的脚本
      • 存放技能文件
      • 存放记忆文件

      最后,向导会显示总结:

      🎉 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
      

      最简单的方式

      openclaw agent --message "你好"

      带思考等级

      # 快速回答
      openclaw agent --message "1+1 等于几" --thinking low
      # 深度思考
      openclaw agent --message "帮我写个 Python 脚本" --thinking high
      # 最高思考等级(最贵但最聪明)
      openclaw agent --message "分析这个项目的架构" --thinking ultra

      连续对话

      openclaw agent
      # 进入交互模式,可以一直聊天
      # 输入 exit 退出
      

      发送测试消息

      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"

      OpenClaw 提供网页版聊天界面(Control UI),比命令行更直观!

      方法 1:运行 dashboard 命令

      openclaw dashboard

      这会自动在浏览器打开控制面板。

      方法 2:手动访问

      1. 确保网关已启动:openclaw gateway
      2. 打开浏览器
      3. 访问:http://127.0.0.1:18789/

      步骤 3:开始聊天

      在网页中:

      1. 看到聊天界面
      2. 在输入框输入消息
      3. Enter 或点击发送
      4. AI 会立即回复

      WebUI 功能

      • ✅ 实时对话(类似 ChatGPT 界面)
      • ✅ 查看对话历史
      • ✅ 切换模型
      • ✅ 调整思考等级
      • ✅ 导出聊天记录

      远程访问(从其他设备访问):

      openclaw ui --host 0.0.0.0 --port 3000

      然后在其他设备访问:http://服务器IP:3000

      查看已安装的技能

      openclaw skills list

      安装新技能

      openclaw skills install <技能名>

      启用/禁用技能

      openclaw skills enable <技能名>
      openclaw skills disable <技能名>

      更新技能

      openclaw skills update

      查看已安装的扩展

      openclaw extensions list

      安装扩展

      openclaw extensions install <扩展名>

      查看已连接的通道

      openclaw channels list

      添加新通道

      openclaw channels add
      # 跟着向导选择平台并配置

      移除通道

      openclaw channels remove <通道名>

      查看整体状态

      openclaw status

      输出示例

      OpenClaw Status
      ===============
      Gateway: Running ✓
      Port: 18789
      Model: qwen-max
      Channels: 0
      Skills: 5
      Uptime: 2h 30m

      查看最近的日志

      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

      自动检查问题

      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

      重启网关

      openclaw gateway restart

      停止网关

      openclaw gateway stop

      启动网关

      openclaw gateway start

      问题 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

      命令 说明 示例
      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.json AI 模型、平台配置
      日志文件 ~/.openclaw/logs/ 运行日志
      工作目录 ~/.openclaw/workspace/ 你的文件和脚本
      技能目录 ~/.openclaw/skills/ 安装的技能
      扩展目录 ~/.openclaw/extensions/ 安装的扩展
      记忆文件 ~/.openclaw/memory/ 对话历史

      快速打开配置文件夹

      Windows

      explorer %USERPROFILE%.openclaw

      Mac

      open ~/.openclaw

      Linux

      cd ~/.openclaw

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

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

      # 1. 在新电脑安装 OpenClaw
      curl -fsSL https://openclaw.ai/install.sh | bash
      # 2. 复制配置文件
      cp ~/.openclaw/openclaw.json 新电脑:~/.openclaw/
      # 3. 重启服务
      openclaw gateway restart

      # 通义千问
      openclaw usage
      # 或访问控制台
      # https://dashscope.console.aliyun.com/usage

      # 方法 1:重新运行配置向导
      openclaw onboard
      # 方法 2:手动编辑配置
      openclaw config edit
      # 修改 model.provider 和 model.apiKey

      # macOS/Linux
      openclaw gateway --daemon
      # Windows(PowerShell)
      Start-Process openclaw gateway -WindowStyle Hidden

      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 分钟

      以上就是OpenClaw从安装到使用的完整教程(官方脚本版)的详细内容,更多关于OpenClaw安装到使用的教程的资料请关注风君子博客其它相关文章!

      站内搜索