OpenClaw 接入指南(小白教程)
OpenClaw 是一个开源的 AI 助手网关,5分钟就能搭建完成。
🌟 什么是 OpenClaw?
简单理解: OpenClaw 是一个"桥梁",连接你的聊天软件(Telegram、Discord 等)和 AI 模型(GPT-4、Claude 等)。
你可以用它:
- 📱 在 Telegram 中与 AI 对话
- 💻 在 Discord 中与 AI 对话
- 🌐 在浏览器中与 AI 对话
- 🤖 使用多种 AI 模型
为什么选择 OpenClaw?
- ✅ 免费开源 - 不需要付费订阅
- ✅ 多平台 - 支持 10+ 聊天平台
- ✅ 多模型 - 支持 GPT-4、Claude、Gemini 等
- ✅ 自己控制 - 数据在你自己的服务器
- ✅ 5分钟搭建 - 官方提供一键安装
📦 第一步:安装 OpenClaw(2分钟)
1.1 检查 Node.js
OpenClaw 需要 Node.js(版本 22 或更高)。
检查方法:
node --version如果显示:
v22.x.x或更高 → ✅ 可以继续v20.x.x或更低 → ❌ 需要先安装 Node.jscommand not found→ ❌ 需要先安装 Node.js
1.2 安装 Node.js(如果需要)
macOS:
# 使用 Homebrew 安装
brew install nodeLinux:
# 使用 nvm 安装
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash
nvm install 22
nvm use 22Windows:
- 访问 https://nodejs.org
- 下载 Node.js 22 LTS 版本
- 双击安装
1.3 安装 OpenClaw
macOS / Linux:
# 一键安装(推荐)
curl -fsSL https://get.openclaw.ai | bashWindows (PowerShell):
# 一键安装
iwr -useb https://get.openclaw.ai/windows | iex验证安装:
openclaw --version如果显示版本号,说明安装成功!
🔧 第二步:配置 Next API(2分钟)
2.1 运行配置向导
# 启动配置向导
openclaw onboard --install-daemon2.2 按提示配置
配置向导会问你几个问题:
问题 1:选择模型提供商
? Choose model provider:
❯ Anthropic (Claude)
OpenAI (GPT)
Google (Gemini)
Custom (自定义)选择: Custom(自定义)
问题 2:输入 API Base URL
? API Base URL:输入: https://api.nextapi.pro/v1
问题 3:输入 API Key
? API Key:输入: sk-你的密钥(从 Next API 获取)
问题 4:选择默认模型
? Default model:输入: gpt-4o-mini(最便宜)
2.3 完成配置
配置完成后,OpenClaw 会自动启动 Gateway。
🚀 第三步:开始使用(1分钟)
3.1 检查 Gateway 是否运行
openclaw gateway status应该显示:
Gateway is running on port 187893.2 打开控制界面
openclaw dashboard浏览器会自动打开 http://localhost:18789
3.3 发送第一条消息
在浏览器中输入:
你好,请介绍一下你自己AI 会回复:
你好!我是 OpenClaw AI 助手...📱 第四步:配置 Telegram(可选,5分钟)
如果你想从手机 Telegram 与 AI 对话,需要配置 Telegram Bot。
4.1 创建 Telegram Bot
步骤 1:打开 Telegram
在 Telegram 中搜索 @BotFather
步骤 2:创建 Bot
发送消息:
/newbot步骤 3:输入 Bot 名称
MyAIAssistant步骤 4:输入 Bot 用户名
my_ai_assistant_bot(必须以 _bot 结尾)
步骤 5:复制 Bot Token
BotFather 会返回:
Done! Congratulations on your new bot...
Use this token to access the HTTP API:
1234567890:ABCdefGHIjklMNOpqrsTUVwxyz
Keep your token secure...复制这个 Token: 1234567890:ABCdefGHIjklMNOpqrsTUVwxyz
4.2 获取你的 Telegram 用户 ID
方法一:使用 @userinfobot
- 在 Telegram 中搜索
@userinfobot - 发送任意消息
- 它会返回你的用户 ID(如:
123456789)
方法二:使用 @RawDataBot
- 在 Telegram 中搜索
@RawDataBot - 发送任意消息
- 它会返回 JSON,找到
from.id
4.3 配置 OpenClaw
编辑配置文件:~/.openclaw/openclaw.json
找到 channels 部分,添加 Telegram 配置:
{
"channels": {
"telegram": {
"enabled": true,
"token": "1234567890:ABCdefGHIjklMNOpqrsTUVwxyz",
"allowFrom": ["123456789"]
}
}
}重要说明:
token:你的 Bot TokenallowFrom:你的用户 ID(不是用户名!)
4.4 重启 Gateway
openclaw gateway restart4.5 在 Telegram 中测试
- 在 Telegram 中搜索你的 Bot 用户名
- 发送消息:
你好 - AI 会回复!
💡 使用技巧
1. 选择合适的模型
| 任务 | 推荐模型 | 价格 |
|---|---|---|
| 日常对话 | gpt-4o-mini | 最便宜 |
| 写代码 | claude-sonnet-4-6 | 性价比高 |
| 复杂推理 | gpt-4o | 性能强 |
| 中文任务 | qwen3-max | 中文好 |
2. 切换模型
在对话中输入:
/model gpt-4o3. 查看状态
# 查看本地状态
openclaw status
# 查看完整诊断
openclaw status --all
# 查看健康状态
openclaw health --json4. 查看日志
# 查看实时日志
openclaw logs
# 查看日志文件
cat ~/.openclaw/logs/openclaw-2026-05-05.log❓ 常见问题
Q1: 安装后无法运行?
检查:
# 检查 Node.js 版本
node --version
# 检查 OpenClaw 版本
openclaw --version
# 检查配置
openclaw doctorQ2: Gateway 无法启动?
检查:
# 查看状态
openclaw gateway status
# 查看日志
openclaw logs
# 重启
openclaw gateway restartQ3: Telegram Bot 不回复?
检查:
- Bot Token 是否正确
- 用户 ID 是否正确(不是用户名)
- Gateway 是否运行
- 配置文件是否正确
常见错误:
// ❌ 错误:使用了用户名
"allowFrom": ["@myusername"]
// ✅ 正确:使用用户 ID
"allowFrom": ["123456789"]Q4: 如何更新 OpenClaw?
# npm 方式
npm update -g openclaw
# 或重新安装
curl -fsSL https://get.openclaw.ai | bashQ5: 如何卸载 OpenClaw?
# 停止 Gateway
openclaw gateway stop
# 卸载
npm uninstall -g openclaw
# 删除配置(可选)
rm -rf ~/.openclaw🎯 推荐配置
最简配置(适合新手)
{
"gateway": {
"mode": "local"
},
"models": {
"providers": {
"nextapi": {
"baseUrl": "https://api.nextapi.pro/v1",
"apiKey": "sk-你的密钥",
"api": "openai",
"models": [
{
"id": "gpt-4o-mini",
"name": "GPT-4o Mini"
}
]
}
}
},
"channels": {
"telegram": {
"enabled": true,
"token": "你的Bot Token",
"allowFrom": ["你的用户ID"]
}
}
}多模型配置
{
"models": {
"providers": {
"nextapi": {
"baseUrl": "https://api.nextapi.pro/v1",
"apiKey": "sk-你的密钥",
"api": "openai",
"models": [
{
"id": "gpt-4o-mini",
"name": "GPT-4o Mini(便宜)"
},
{
"id": "claude-sonnet-4-6",
"name": "Claude Sonnet(写代码)"
},
{
"id": "gpt-4o",
"name": "GPT-4o(强大)"
}
]
}
}
}
}