OpenClaw 中文教程
从入门到精通,打造你的专属 AI 助手
📦 1. 快速安装
系统要求
Node.js >= 18.0 pnpm >= 8.0 Linux / macOS / Windows (WSL2)
一键安装
# 使用 npm 全局安装
npm install -g openclaw
# 或者使用 pnpm
pnpm add -g openclaw
openclaw --version 验证安装
启动 Gateway
# 启动 OpenClaw Gateway
openclaw gateway start
# 查看状态
openclaw gateway status
http://127.0.0.1:18789
⚙️ 2. 基础配置
配置文件位置
~/.openclaw/openclaw.json
配置模型
{
"models": {
"providers": {
"bailian": {
"baseUrl": "https://dashscope.aliyuncs.com/api/v1",
"apiKey": "sk-your-api-key",
"models": [
{
"id": "qwen-plus",
"name": "通义千问 Plus",
"contextWindow": 32000
}
]
}
}
}
}
配置工作区
{
"agents": {
"defaults": {
"workspace": "/home/your-name/openclaw-workspace"
}
}
}
☁️ 2.5 阿里云百炼 Coding Plan 配置
获取 API Key
- 访问 阿里云百炼控制台
- 登录阿里云账号
- 进入 Coding Plan 页面
- 创建或选择已有的 API Key
- 复制 API Key(格式类似:
sk-xxxxxxxxxxxxxxxx)
方式一:通过 Web UI 配置(推荐)
# 打开 Web UI
openclaw dashboard
在 Web UI 左侧菜单选择 Settings → Config,复制以下内容到 Raw JSON 输入框:
{
"models": {
"mode": "merge",
"providers": {
"bailian": {
"baseUrl": "https://coding.dashscope.aliyuncs.com/v1",
"apiKey": "YOUR_API_KEY",
"api": "openai-completions",
"models": [
{ "id": "qwen3.5-plus", "name": "qwen3.5-plus", "contextWindow": 1000000, "maxTokens": 65536 },
{ "id": "qwen3-max-2026-01-23", "name": "qwen3-max-2026-01-23", "contextWindow": 262144 },
{ "id": "qwen3-coder-next", "name": "qwen3-coder-next", "contextWindow": 262144 },
{ "id": "qwen3-coder-plus", "name": "qwen3-coder-plus", "contextWindow": 1000000 },
{ "id": "MiniMax-M2.5", "name": "MiniMax-M2.5", "contextWindow": 196608 },
{ "id": "glm-5", "name": "glm-5", "contextWindow": 202752 },
{ "id": "kimi-k2.5", "name": "kimi-k2.5", "contextWindow": 262144 }
]
}
}
},
"agents": {
"defaults": {
"model": { "primary": "bailian/qwen3.5-plus" }
}
},
"gateway": { "mode": "local" }
}
YOUR_API_KEY 替换为你的 Coding Plan 专属 API Key
切换模型
临时切换(当前会话有效):
# 进入 TUI 界面
openclaw tui
# 使用 /model 命令切换
/model qwen3-coder-next
qwen3.5-plus - 综合性能最佳,适合日常使用qwen3-coder-plus - 编程专用,代码能力更强qwen3-max-2026-01-23 - 最强模型,适合复杂任务
💬 3. 消息渠道配置
飞书 (Feishu)
{
"channels": {
"feishu": {
"enabled": true,
"dmPolicy": "pairing",
"accounts": {
"main": {
"appId": "cli_xxxxxxxxxxxxx",
"appSecret": "xxxxxxxxxxxxxxxx",
"botName": "我的 OpenClaw"
}
}
}
}
}
Telegram
{
"channels": {
"telegram": {
"enabled": true,
"accounts": {
"main": {
"botToken": "123456789:ABCdefGHIjklMNOpqrsTUVwxyz"
}
}
}
}
}
🛠️ 4. 工具与技能
内置工具组
group:fs- 文件系统操作browser- 浏览器控制group:runtime- 代码执行group:automation- 自动化任务group:openclaw- OpenClaw 管理
安装技能
# 使用 clawhub 安装技能
npx clawhub install weather
# 查看已安装技能
npx clawhub list
🧠 5. 记忆系统
记忆文件结构
workspace/
├── MEMORY.md # 长期记忆
├── SOUL.md # 人格定义
├── USER.md # 用户信息
├── IDENTITY.md # 身份定义
├── HEARTBEAT.md # 心跳任务
└── memory/
├── 2026-03-11.md # 每日记忆
└── 2026-03-12.md
🚀 6. 进阶功能
Tailscale 远程访问
{
"gateway": {
"bind": "tailnet",
"port": 18789,
"auth": {
"mode": "token",
"token": "your-secure-token"
}
}
}
定时任务 (Cron)
# 配置定时提醒
openclaw cron add --schedule "0 9 * * *" --message "早上好!今日待办..."
Cloudflare Tunnel 公网访问
# 安装 cloudflared
# 配置隧道
cloudflared tunnel create my-tunnel
# 运行隧道
cloudflared tunnel run my-tunnel
❓ 7. 常见问题
Q: Gateway 启动失败?
A: 检查端口是否被占用,查看日志:
openclaw logs --tail 50
Q: 如何备份配置?
A: 备份整个 ~/.openclaw 目录:
tar -czf openclaw-backup.tar.gz ~/.openclaw
Q: 如何更新 OpenClaw?
A: 使用以下命令更新:
openclaw update