第2章 三步快速上手 - 3 分钟完成首次对话
第2章 三步快速上手
让我们用最快的速度体验 OpenClaw!本章将带你在 3 分钟内完成安装、配置和首次对话。
🎯 本章目标
-
全局安装 OpenClaw CLI
-
使用向导完成初始化配置
-
成功进行第一次对话
-
验证安装是否正确
前置准备检查
在开始之前,请确保:
# 1. 检查 Node.js 版本(必须 >= 22)
node -v
# 应该输出 v22.x.x 或更高
# 2. 检查 npm 或 pnpm
npm -v
# 或
pnpm -v
# 3. 准备好至少一个大模型 API Key
第一步:全局安装 OpenClaw CLI
使用 npm 安装(推荐)
npm install -g openclaw@latest
使用 pnpm 安装(更快)
pnpm add -g openclaw@latest
验证安装
openclaw --version
openclaw --help
第二步:初始化向导
openclaw onboard
这个命令会启动一个交互式向导,引导你完成初始配置。
向导流程
-
选择工作目录 - 默认
~/.openclaw/workspace -
选择模型提供商 - OpenAI / Claude / 通义千问等
-
配置 API Key - 输入你的 API Key
-
选择 Skills - 选择要安装的技能
-
配置渠道(可选)- 跳过或配置聊天平台
-
安装守护进程(可选)- 首次建议跳过
第三步:第一次对话
命令行对话
openclaw agent --message "你好,请介绍一下你自己"
交互式对话
openclaw agent --interactive
指定参数
openclaw agent --message "写一个 Python 快速排序" --model gpt-4o --thinking high
验证安装
运行健康检查
openclaw doctor
查看配置
openclaw config list
查看已安装的 Skills
openclaw skills list
常见问题排查
问题 1:权限错误
# 修改 npm 全局目录权限
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
echo 'export PATH=~/.npm-global/bin:$PATH' >> ~/.bashrc
source ~/.bashrc
问题 2:网络超时
# 使用淘宝镜像
npm install -g openclaw@latest --registry=https://registry.npmmirror.com
问题 3:API Key 无效
openclaw config set model.apiKey sk-proj-xxxxxxxxxxxxx
下一步
📚 本章小结
✅ 全局安装 OpenClaw CLI
✅ 使用 openclaw onboard 完成初始化
✅ 成功进行了第一次对话
✅ 验证了安装是否正确