OpenClaw 安装部署完整指南
2026-02-27 · 阅读约 5 分钟 · 教程
OpenClaw 是一款强大的 AI 编程助手 CLI,支持 Claude、GPT、Gemini 等主流大模型。本文将手把手教你从零安装配置,包括一键脚本和手动安装两种方式。
前置要求
- Node.js >= 22(安装脚本会自动处理)
- macOS / Linux / Windows 系统
- ClawGate API Key(免费注册获取,送 ¥1 体验金)
方式一:一键安装(推荐)
最简单的方式,一行命令搞定一切:
macOS / Linux
curl -fsSL https://xiaoclaw.com/i | bash
带 API Key 的非交互模式:
curl -fsSL https://xiaoclaw.com/i | bash -s -- --key sk-cg-你的Key --yes
Windows (PowerShell)
irm https://xiaoclaw.com/install.ps1 | iex
带参数:
irm https://xiaoclaw.com/install.ps1 -OutFile $env:TEMP\i.ps1; powershell -EP Bypass -File $env:TEMP\i.ps1 -Key "sk-cg-你的Key"
安装脚本会自动:
- 检测并安装 Node.js(如果版本不够会自动升级)
- 安装 OpenClaw CLI
- 验证你的 API Key
- 写入配置文件
- 启动 Gateway 服务
方式二:手动安装
1. 安装 Node.js
# macOS (Homebrew)
brew install node@22
# Ubuntu / Debian
curl -fsSL https://deb.nodesource.com/setup_22.x | sudo bash -
sudo apt install -y nodejs
# Windows
winget install OpenJS.NodeJS.LTS
2. 安装 OpenClaw
npm install -g openclaw
3. 配置 ClawGate API
编辑 ~/.openclaw/openclaw.json,添加 ClawGate 作为 provider:
{
"models": {
"providers": {
"clawgate": {
"baseUrl": "https://xiaoclaw.com",
"apiKey": "sk-cg-你的Key",
"api": "anthropic-messages"
}
}
}
}
4. 启动
# 启动后台服务
openclaw gateway start
# 开始对话
openclaw
配置 Telegram Bot(可选)
如果你想通过 Telegram 和 AI 聊天:
- 在 Telegram 搜索
@BotFather,发送/newbot创建 Bot - 获取 Bot Token
- 安装时选择「Telegram Bot」并输入 Token
可用模型
ClawGate 支持以下模型,全部官方五折:
- Anthropic:Claude Opus 4.6、Sonnet 4.5、Haiku 4.5
- OpenAI:GPT-5.2、GPT-5.2 Codex
- Google:Gemini 2.5 Pro、Gemini 2.5 Flash
- xAI:Grok-3
在对话中输入 /model 即可切换模型。
常见问题
Q: 安装后 openclaw 命令找不到?
关闭终端重新打开,或运行 hash -r 刷新 PATH。
Q: Gateway 启动失败?
检查端口 18789 是否被占用:lsof -i :18789
Q: API Key 验证失败?
确认 Key 以 sk-cg- 开头,在 仪表盘 检查 Key 状态。
还有问题?查看 完整使用指南 或 API 文档。