OpenClaw 接入 GLM Coding Plan 完整指南
在 OpenClaw 中使用智谱 GLM 模型的详细配置教程
OpenClaw 是一个在您自己的设备上运行的个人 AI 助手,可以连接到各种消息平台。通过 GLM Coding Plan,您可以配置使用智谱的 GLM 模型。 ---
⚠️ 重要提示
GLM Coding Plan 支持 OpenClaw 使用,但采用次级调度与尽力交付策略
Coding Agent 任务享有资源抢占优先权
高负载下 OpenClaw 任务将自动触发动态排队、限流等公平使用策略
---
📋 配置步骤
1️⃣ 获取 API Key
1. 访问 [智谱开放平台](https://open.bigmodel.cn),注册或登录 2. 在 [API Keys 管理页面](https://open.bigmodel.cn/usercenter/proj-mgmt/apikeys) 创建一个 API Key 3. 确保您已订阅 [GLM Coding Plan](https://zhipuaishengchan.datasink.sensorsdata.cn/t/Nd) ---
2️⃣ 安装 OpenClaw
前置条件: Node.js 22 或更新版本 macOS/Linux: ```bash curl -fsSL https://openclaw.ai/install.sh | bash ``` Windows (PowerShell): ```powershell iwr -useb https://openclaw.ai/install.ps1 | iex ``` 或手动安装: ```bash npm install -g openclaw@latest
或
pnpm add -g openclaw@latest pnpm approve-builds -g ``` ---
3️⃣ 设置 OpenClaw
运行安装命令后,配置过程将自动开始。如果没有开始,可以运行: ```bash openclaw onboard --install-daemon ``` 配置选项:
`I understand this is powerful and inherently risky. Continue?` → Yes
`Onboarding mode` → Quick Start
`Model/auth provider` → Z.AI
---
4️⃣ 配置 Z.AI 提供商
1. 选择 `Coding-Plan-CN` 2. 输入智谱 API Key 3. 选择模型:`zai/glm-5.1`、`zai/glm-4.7`、`zai/glm-4.5-air`
⚠️ 重要提示: 请勿选择 Flash/FlashX 模型,以免造成额外扣费。仅支持:GLM-5.1、GLM-5-Turbo、GLM-4.7、GLM-4.5-Air
---
5️⃣ 完成设置
`Select channel` → 选择并配置需要的功能
`Configure skills` → 选择并安装需要的技能
完成设置
---
6️⃣ 与机器人交互
```bash openclaw tui ``` 也可通过 Web UI、Discord、Slack 等渠道交互。 ---
7️⃣ 安装后验证
```bash openclaw doctor # 检查配置问题 openclaw status # 查看网关状态 openclaw dashboard # 浏览器打开 Dashboard ``` ---
🔄 切换到 GLM-5.1 模型
编辑 `~/.openclaw/openclaw.json` 文件:
1. 添加模型配置
在 `models.providers.zai.models` 数组中添加: ```json { "id": "glm-5.1", "name": "GLM-5.1", "reasoning": true, "input": ["text"], "cost": {"input": 0, "output": 0, "cacheRead": 0, "cacheWrite": 0}, "contextWindow": 204800, "maxTokens": 131072 } ```
2. 修改默认模型
```json "agents": { "defaults": { "model": { "primary": "zai/glm-5.1", "fallbacks": ["zai/glm-4.7"] } } } ```
3. 重启网关
```bash openclaw gateway restart ``` ---
⚙️ 高级配置
模型故障转移
```json { "agents": { "defaults": { "model": { "primary": "zai/glm-5.1", "fallbacks": ["zai/glm-4.7", "zai/glm-4.6", "zai/glm-4.5-air"] } } } } ```
技能管理
```bash
安装 clawhub
npm i -g clawhub
搜索技能
clawhub search "postgres backups"
安装技能
clawhub install my-skill-pack
更新技能
clawhub update --all ```
插件管理
```bash
查看已加载的插件
openclaw plugins list
安装官方插件
openclaw plugins install @openclaw/voice-call
重启网关
openclaw gateway restart ``` ---
🔧 故障排除
常见问题
1. API Key 认证
确保智谱 API key 有效且已订阅 GLM Coding Plan
检查 API key 在环境中是否正确设置
2. 模型可用性
验证 GLM 模型在您所在的地区是否可用
检查模型名称格式
3. 连接问题
确保 OpenClaw gateway 正在运行
检查到智谱端点的网络连接
---
📚 相关资源
[OpenClaw 官方文档](https://docs.openclaw.ai/)
[OpenClaw GitHub](https://github.com/openclaw/openclaw)
[智谱开发者文档](https://docs.bigmodel.cn/)
[ClawHub 技能市场](https://clawhub.ai/)
---
💡 安全提示: 若配置不当或在没有适当访问控制的情况下部署,OpenClaw 可能会涉及安全风险。请参考[官方安全文档](https://docs.openclaw.ai/gateway/security)。
评论区