OpenClaw 安装与配置指南¶
日期:2026-04-17 环境:macOS Darwin 25.3.0 (Apple Silicon) / Node.js v25.9.0
一、简介¶
OpenClaw 是一款开源的个人 AI 助手,支持多平台(macOS / Linux / Windows / Android / Raspberry Pi),可通过 Gateway 连接多种 AI 模型,并支持 Telegram、Discord 等通道接入。
二、安装¶
环境要求¶
| 项目 | 要求 |
|---|---|
| Node.js | 22.14+ (推荐 24+) |
| 包管理器 | npm / pnpm / bun |
安装命令¶
# npm 安装(推荐)
npm install -g openclaw@latest
# 或 pnpm
pnpm add -g openclaw@latest
# 或一键脚本(自动装 Node)
curl -fsSL https://openclaw.ai/install-cli.sh | bash
安装验证¶
安装记录¶
| 项目 | 详情 |
|---|---|
| 安装日期 | 2026-04-17 |
| 安装方式 | npm install -g openclaw@latest |
| 安装版本 | OpenClaw 2026.4.15 (041266a) |
| 安装路径 | /opt/homebrew/bin/openclaw |
| 系统环境 | macOS Darwin 25.3.0, Node.js v25.9.0, npm 11.12.1 |
安装警告
安装过程中会出现 inflight、gauge、glob 等旧版依赖的弃用警告,不影响功能,可忽略。
三、配置¶
方式一:交互式向导(推荐)¶
引导完成 Gateway 模式、API 密钥、通道等所有配置。
方式二:一步到位¶
一次性完成 Gateway 配置 + 模型认证 + 工作区设置 + 可选通道连接。
核心配置项¶
配置文件位于 ~/.openclaw/openclaw.json。
Gateway 模式¶
API 密钥¶
将密钥存放在 ~/.openclaw/.env:
# 创建 .env 文件
cat > ~/.openclaw/.env << 'EOF'
ANTHROPIC_API_KEY=sk-ant-your-key-here
OPENAI_API_KEY=sk-your-key-here
EOF
# 设置权限(重要!)
chmod 600 ~/.openclaw/.env
在 openclaw.json 中通过 ${ANTHROPIC_API_KEY} 语法引用。
模型管理¶
# 查看可用模型
openclaw models list
# 扫描本地模型(Ollama 等)
openclaw models scan
# 配置默认模型
openclaw models --help
四、启动与使用¶
启动 Gateway¶
# 默认端口 18789
openclaw gateway
# 指定端口
openclaw gateway --port 18789
# 强制启动(杀掉占用端口的进程)
openclaw gateway --force
# 开发模式(隔离状态,端口 19001)
openclaw --dev gateway
常用命令速查¶
| 命令 | 说明 |
|---|---|
openclaw configure | 交互式配置 |
openclaw doctor | 健康检查 + 快速修复 |
openclaw gateway | 启动 WebSocket Gateway |
openclaw dashboard | 打开浏览器控制台 |
openclaw tui | 终端 UI |
openclaw status | 通道健康与会话状态 |
openclaw channels login | 连接聊天通道 |
openclaw logs | 查看 Gateway 日志 |
openclaw memory | 搜索/查看记忆文件 |
openclaw update | 更新到最新版本 |
发送消息¶
# 通过 Gateway 发送消息
openclaw message send --target +15555550123 --message "Hello"
# 通过 Telegram 发送
openclaw message send --channel telegram --target @mychat --message "Hi"
Agent 模式¶
五、进阶配置¶
通道接入¶
# 管理通道(Telegram / Discord / WhatsApp 等)
openclaw channels --help
# 登录 WhatsApp Web
openclaw channels login --verbose