一、环境准备
OpenClaw基于Node.js运行,部署前需要安装以下环境:
- Node.js ≥ v18(推荐 v20+),前往 nodejs.org 下载安装
- Git,用于克隆仓库
- AI模型API Key:OpenAI / Claude / 其他兼容API的密钥
二、安装 OpenClaw
# 克隆项目
git clone https://github.com/openclaw/openclaw.git
cd openclaw
# 安装依赖
npm install
# 初始化配置
npx openclaw init
💡 提示:如果在国内网络环境下安装较慢,可使用镜像源:
npm install --registry=https://registry.npmmirror.com
三、配置 AI 模型
编辑配置文件,填入你的API Key:
# 编辑配置文件
npx openclaw config edit
# 主要配置项:
# - provider: openai / claude / custom
# - apiKey: 你的API密钥
# - model: gpt-4o / claude-sonnet 等
# - channel: 配置消息通道(微信/Telegram等)
四、启动运行
# 启动网关服务
npx openclaw gateway start
# 查看运行状态
npx openclaw gateway status
# 交互式对话
npx openclaw chat
⚠️ 注意:API Key请妥善保管,不要上传到公开仓库或分享给他人。
五、常用命令速查
openclaw gateway start # 启动服务
openclaw gateway stop # 停止服务
openclaw gateway restart # 重启服务
openclaw gateway status # 查看状态
openclaw chat # 开始对话
openclaw help # 查看帮助