OpenClaw從安裝到使用的完整教程(官方腳本版)
本教程基于 OpenClaw 官方文檔和安裝腳本編寫,保證準確!
OpenClaw 是什么?
OpenClaw 是一個個人 AI 助手框架,讓你可以在本地運行自己的 AI 助手。
它能幫你做什么?
- ? 聊天問答(微信、QQ、Telegram、Discord 等)
- ? 寫文章、寫代碼
- ? 定時提醒
- ? 自動化任務
- ? 瀏覽器操作
- ? 文件處理
最大的好處:數(shù)據(jù)在自己電腦上,隱私安全!
一鍵安裝(1 條命令)
打開命令行,復制粘貼以下命令:
curl -fsSL https://openclaw.ai/install.sh | bash
等待安裝完成,過程大約 2-5 分鐘。
配置向?qū)г敿毩鞒?/h2>
安裝完成后,會自動進入配置向?qū)?/strong> (openclaw onboard)。
第 1 步:歡迎界面
?? Welcome to OpenClaw! This wizard will help you set up your personal AI assistant.
按 Enter 繼續(xù)。
第 2 步:選擇 AI 模型
向?qū)@示可選的 AI 模型:
Select your AI provider: ○ OpenAI (GPT-4) ● Dashscope (通義千問) ← 推薦國內(nèi)用戶 ○ Anthropic (Claude) ○ Google (Gemini) ○ Skip for now
操作方法:
- 用
↑↓方向鍵選擇 - 按
Enter確認
模型推薦:
- 國內(nèi)用戶:選 Dashscope(通義千問),速度快,便宜
- 有 OpenAI:選 OpenAI,模型最強
- 有 Claude:選 Anthropic,長文本厲害
第 3 步:填寫 API Key
選擇模型后,輸入 API Key:
Enter your Dashscope API Key: > sk-____________________
如何獲取 API Key?
通義千問(Dashscope):
- 訪問:dashscope.console.aliyun.com/
- 登錄阿里云賬號(沒有就注冊一個)
- 點擊左側(cè)"API Key 管理"
- 點擊"創(chuàng)建新的 API Key"
- 復制生成的 Key(以
sk-開頭) - 粘貼到向?qū)Ю?/li>
OpenAI:
- 訪問:platform.openai.com/
- 登錄或注冊
- 點擊左側(cè)"API Keys"
- 點擊"Create new secret key"
- 復制 Key(以
sk-proj-或sk-開頭)
Claude(Anthropic):
- 訪問:console.anthropic.com/
- 登錄或注冊
- 點擊"Get API keys"
- 點擊"Create key"
- 復制 Key(以
sk-ant-開頭)
第 4 步:測試連接
向?qū)y試 API Key 是否有效:
Testing connection to Dashscope... ? Connection successful! Model: qwen-max Credits remaining: ¥100.00
如果失敗,會提示你重新輸入。
第 5 步:選擇連接平臺
向?qū)柲阋B接哪些聊天平臺:
Select platforms to connect: ○ WhatsApp ○ Telegram ○ Discord ○ Slack ○ WeChat (微信) ○ QQ ○ Skip for now ← 新手建議先選這個
新手建議:
- 先選
Skip for now(跳過) - 等 OpenClaw 運行正常后再配置平臺
- 配置平臺需要額外的 Bot ID 或 Token
后續(xù)配置: 運行 openclaw channels add 可以添加平臺
第 6 步:安裝后臺服務
向?qū)柺欠癜惭b后臺服務(開機自啟):
Install Gateway daemon? This will start OpenClaw automatically on boot. ● Yes (recommended) ○ No
建議:
- 選
Yes:OpenClaw 會一直運行,隨時可用 - 選
No:每次需要手動運行openclaw gateway
后臺服務類型:
- macOS:launchd
- Linux:systemd
- Windows:WSL2 或手動運行
第 7 步:配置工作目錄
向?qū)O置工作目錄:
Workspace location: > /Users/你的用戶名/.openclaw/workspace Change location? (y/N)
建議:
- 直接按
Enter使用默認位置 - 如果需要改,輸入
y然后輸入新路徑
工作目錄用途:
- 存放你的腳本
- 存放技能文件
- 存放記憶文件
第 8 步:完成配置
最后,向?qū)@示總結(jié):
?? 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 "分析這個項目的架構(gòu)" --thinking ultra
連續(xù)對話:
openclaw agent # 進入交互模式,可以一直聊天 # 輸入 exit 退出
2. 發(fā)送消息
發(fā)送測試消息:
openclaw message send --message "Hello from OpenClaw"
發(fā)送到指定平臺:
# 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 提供網(wǎng)頁版聊天界面(Control UI),比命令行更直觀!
方法 1:運行 dashboard 命令
openclaw dashboard
這會自動在瀏覽器打開控制面板。
方法 2:手動訪問
- 確保網(wǎng)關(guān)已啟動:
openclaw gateway - 打開瀏覽器
- 訪問:http://127.0.0.1:18789/
步驟 3:開始聊天
在網(wǎng)頁中:
- 看到聊天界面
- 在輸入框輸入消息
- 按
Enter或點擊發(fā)送 - AI 會立即回復
WebUI 功能:
- ? 實時對話(類似 ChatGPT 界面)
- ? 查看對話歷史
- ? 切換模型
- ? 調(diào)整思考等級
- ? 導出聊天記錄
遠程訪問(從其他設備訪問):
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 # 跟著向?qū)нx擇平臺并配置
移除通道:
openclaw channels remove <通道名>
調(diào)試和排錯
1. 查看狀態(tài)
查看整體狀態(tài):
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. 運行醫(yī)生檢查
自動檢查問題:
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. 重啟服務
重啟網(wǎng)關(guān):
openclaw gateway restart
停止網(wǎng)關(guān):
openclaw gateway stop
啟動網(wǎng)關(guān):
openclaw gateway start
5. 常見問題排查
問題 1:AI 不回復
檢查步驟:
# 1. 檢查網(wǎng)關(guān)狀態(tài) openclaw status # 2. 檢查 API Key openclaw doctor # 3. 查看日志 openclaw logs --level error # 4. 測試連接 openclaw agent --message "test"
問題 2:消息發(fā)送失敗
檢查步驟:
# 1. 檢查通道配置 openclaw channels list # 2. 檢查通道狀態(tài) 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 | 查看狀態(tài) | openclaw status |
openclaw doctor | 檢查問題 | openclaw doctor |
openclaw logs | 查看日志 | openclaw logs --follow |
openclaw version | 查看版本 | openclaw version |
openclaw help | 查看幫助 | openclaw help |
網(wǎng)關(guān)命令
| 命令 | 說明 | 示例 |
|---|---|---|
openclaw gateway | 啟動網(wǎng)關(guān) | 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 命令參數(shù):
--message "文本":發(fā)送的消息--thinking low|medium|high|ultra:思考等級--deliver <平臺>:發(fā)送到指定平臺
消息命令
| 命令 | 說明 | 示例 |
|---|---|---|
openclaw message send | 發(fā)送消息 | openclaw message send --to xxx --message "Hi" |
openclaw message broadcast | 群發(fā)消息 | openclaw message broadcast --message "通知" |
配置命令
| 命令 | 說明 | 示例 |
|---|---|---|
openclaw onboard | 配置向?qū)?/td> | 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 | 查看狀態(tài) | openclaw channels status telegram |
更新命令
| 命令 | 說明 | 示例 |
|---|---|---|
openclaw update | 更新 | openclaw update |
openclaw update --channel | 切換版本 | openclaw update --channel beta |
版本通道:
stable:穩(wěn)定版(推薦)beta:測試版dev:開發(fā)版
重要文件位置
| 內(nèi)容 | 位置 | 說明 |
|---|---|---|
| 配置文件 | ~/.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. 如何卸載?
# 1. 停止服務 openclaw gateway stop # 2. 卸載 OpenClaw npm uninstall -g openclaw # 3. 刪除配置(可選) rm -rf ~/.openclaw
2. 如何備份配置?
# 備份整個配置目錄 cp -r ~/.openclaw ~/.openclaw.backup # 或只備份配置文件 cp ~/.openclaw/openclaw.json ~/backup/
3. 如何遷移到另一臺電腦?
# 1. 在新電腦安裝 OpenClaw 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:重新運行配置向?qū)? openclaw onboard # 方法 2:手動編輯配置 openclaw config edit # 修改 model.provider 和 model.apiKey
6. 如何在后臺運行?
# macOS/Linux openclaw gateway --daemon # Windows(PowerShell) Start-Process openclaw gateway -WindowStyle Hidden
總結(jié)
安裝(1 條命令)
curl -fsSL https://openclaw.ai/install.sh | bash
配置(跟著向?qū)ё撸?/h3>
openclaw onboard # 安裝后自動啟動
openclaw onboard # 安裝后自動啟動
使用(常用命令)
# 查看狀態(tài) openclaw status # 和 AI 對話 openclaw agent --message "你好" # 查看日志 openclaw logs # 檢查問題 openclaw doctor
學習路徑
- ? 安裝完成
- ? 運行
openclaw agent測試對話 - ? 配置一個聊天通道(如 Telegram)
- ? 安裝幾個實用技能
- ? 探索自動化功能
總耗時:15-30 分鐘
以上就是OpenClaw從安裝到使用的完整教程(官方腳本版)的詳細內(nèi)容,更多關(guān)于OpenClaw安裝到使用的教程的資料請關(guān)注腳本之家其它相關(guān)文章!
相關(guān)文章
本文詳細介紹了在macOS/Linux/Windows系統(tǒng)上進行本地部署的步驟,并展示了如何配置飛書機器人以實現(xiàn)飛書內(nèi)的AI對話,文中通過示例代碼介紹的非常詳細,需要的朋友們下面隨著2026-03-05
OpenClaw 是一個可以部署在自己服務器上的 AI Agent,能通過 Telegram、飛書等渠道對話,幫你操控系統(tǒng)、定時任務、聯(lián)網(wǎng)搜索、寫代碼部署項目的等等,這篇文章記錄了我完整的2026-03-03
在Mac mini上安裝配置OpenClaw AI助手的詳細過程,包括通過Homebrew安裝、配置模型(如MiniMax、GLM)、連接聊天渠道(WhatsApp、Telegram、Discord),后續(xù)可以參考一下2026-03-03
OpenClaw(原Clawdbot/Moltbot)是一款開源的本地優(yōu)先AI代理與自動化平臺,支持多渠道通信集成、大模型調(diào)用及自動化任務執(zhí)行,可滿足個人與小型團隊的智能輔助需求,這篇文章主2026-03-02





