Skip to main content

OpenClaw

在 OpenClaw 中使用阿里云百炼模型。

快速开始

  1. 1

    安装 Qwen 插件

    openclaw plugins install @openclaw/qwen-provider
    
    无法安装插件时,参考通过配置文件接入。
  2. 2

    获取 API Key

    • Token Plan
    • 按量计费
    • Coding Plan
    按 Token Plan 版本获取 API Key:
  3. 3

    配置模型

    按计费方案运行对应命令,并按提示输入 API Key。
    • Token Plan
    • 按量计费
    • Coding Plan
    openclaw onboard --auth-choice qwen-token-plan-cn
    
  4. 4

    验证

    运行以下命令确认模型列表和调用结果:
    openclaw models list --provider qwen-token-plan
    openclaw agent --model qwen-token-plan/qwen3.8-max --message "只回复 ok"
    

通过配置文件接入

适用于无法安装 Qwen 插件或需要手动管理配置的场景。
  1. 1

    打开或新建配置文件

    ~/.openclaw/openclaw.json只更新 models、agents 和 gateway 中对应字段,不要全量替换已有配置。
  2. 2

    写入配置

    • Token Plan 个人版
    • Token Plan 团队版
    • 按量计费
    • Coding Plan
    将 YOUR_API_KEY 替换为 Token Plan 个人版 API Key。
    {
      "models": {
        "mode": "merge",
        "providers": {
          "bailian-token-plan": {
            "baseUrl": "https://token-plan.cn-beijing.maas.aliyuncs.com/apps/anthropic",
            "apiKey": "YOUR_API_KEY",
            "api": "anthropic-messages",
            "models": [
              {
                "id": "auto",
                "name": "auto",
                "reasoning": false,
                "input": [
                  "text"
                ],
                "contextWindow": 1000000,
                "maxTokens": 393216,
                "cost": {
                  "input": 0,
                  "output": 0,
                  "cacheRead": 0,
                  "cacheWrite": 0
                }
              },
              {
                "id": "qwen4-max",
                "name": "qwen4-max",
                "reasoning": true,
                "input": [
                  "text",
                  "image"
                ],
                "contextWindow": 1000000,
                "maxTokens": 262144,
                "cost": {
                  "input": 0,
                  "output": 0,
                  "cacheRead": 0,
                  "cacheWrite": 0
                }
              },
              {
                "id": "qwen3.8-max",
                "name": "qwen3.8-max",
                "reasoning": true,
                "input": [
                  "text",
                  "image"
                ],
                "contextWindow": 1000000,
                "maxTokens": 131072,
                "cost": {
                  "input": 0,
                  "output": 0,
                  "cacheRead": 0,
                  "cacheWrite": 0
                }
              },
              {
                "id": "qwen3.8-flash",
                "name": "qwen3.8-flash",
                "reasoning": true,
                "input": [
                  "text",
                  "image"
                ],
                "contextWindow": 1000000,
                "maxTokens": 131072,
                "cost": {
                  "input": 0,
                  "output": 0,
                  "cacheRead": 0,
                  "cacheWrite": 0
                }
              },
              {
                "id": "qwen3.7-max",
                "name": "qwen3.7-max",
                "reasoning": true,
                "input": [
                  "text"
                ],
                "contextWindow": 1000000,
                "maxTokens": 65536,
                "cost": {
                  "input": 0,
                  "output": 0,
                  "cacheRead": 0,
                  "cacheWrite": 0
                }
              },
              {
                "id": "qwen3.7-plus",
                "name": "qwen3.7-plus",
                "reasoning": true,
                "input": [
                  "text",
                  "image"
                ],
                "contextWindow": 1000000,
                "maxTokens": 65536,
                "cost": {
                  "input": 0,
                  "output": 0,
                  "cacheRead": 0,
                  "cacheWrite": 0
                }
              },
              {
                "id": "qwen3.6-flash",
                "name": "qwen3.6-flash",
                "reasoning": true,
                "input": [
                  "text",
                  "image"
                ],
                "contextWindow": 1000000,
                "maxTokens": 65536,
                "cost": {
                  "input": 0,
                  "output": 0,
                  "cacheRead": 0,
                  "cacheWrite": 0
                }
              },
              {
                "id": "deepseek-v4.1-flash",
                "name": "deepseek-v4.1-flash",
                "reasoning": true,
                "input": [
                  "text",
                  "image"
                ],
                "contextWindow": 1000000,
                "maxTokens": 65536,
                "cost": {
                  "input": 0,
                  "output": 0,
                  "cacheRead": 0,
                  "cacheWrite": 0
                }
              },
              {
                "id": "deepseek-v4.1-flash-1017",
                "name": "deepseek-v4.1-flash-1017",
                "reasoning": true,
                "input": [
                  "text",
                  "image"
                ],
                "contextWindow": 1000000,
                "maxTokens": 65536,
                "cost": {
                  "input": 0,
                  "output": 0,
                  "cacheRead": 0,
                  "cacheWrite": 0
                }
              },
              {
                "id": "deepseek-v4-pro",
                "name": "deepseek-v4-pro",
                "reasoning": true,
                "input": [
                  "text"
                ],
                "contextWindow": 1000000,
                "maxTokens": 65536,
                "cost": {
                  "input": 0,
                  "output": 0,
                  "cacheRead": 0,
                  "cacheWrite": 0
                }
              },
              {
                "id": "deepseek-v4-pro-0813",
                "name": "deepseek-v4-pro-0813",
                "reasoning": true,
                "input": [
                  "text"
                ],
                "contextWindow": 1000000,
                "maxTokens": 65536,
                "cost": {
                  "input": 0,
                  "output": 0,
                  "cacheRead": 0,
                  "cacheWrite": 0
                }
              },
              {
                "id": "deepseek-v4-flash-0731",
                "name": "deepseek-v4-flash-0731",
                "reasoning": true,
                "input": [
                  "text"
                ],
                "contextWindow": 1000000,
                "maxTokens": 65536,
                "cost": {
                  "input": 0,
                  "output": 0,
                  "cacheRead": 0,
                  "cacheWrite": 0
                }
              },
              {
                "id": "glm-5.3",
                "name": "glm-5.3",
                "reasoning": true,
                "input": [
                  "text"
                ],
                "contextWindow": 202752,
                "maxTokens": 16384,
                "cost": {
                  "input": 0,
                  "output": 0,
                  "cacheRead": 0,
                  "cacheWrite": 0
                }
              },
              {
                "id": "glm-5.2",
                "name": "glm-5.2",
                "reasoning": true,
                "input": [
                  "text"
                ],
                "contextWindow": 202752,
                "maxTokens": 16384,
                "cost": {
                  "input": 0,
                  "output": 0,
                  "cacheRead": 0,
                  "cacheWrite": 0
                }
              }
            ]
          }
        }
      },
      "agents": {
        "defaults": {
          "model": {
            "primary": "bailian-token-plan/auto"
          }
        }
      },
      "gateway": {
        "mode": "local",
        "auth": {
          "mode": "none"
        }
      }
    }
    
    使用 qwen4-max 时,可用 params.cacheRetention 设置 short、long 或 none,long 对应 1 小时 TTL。qwen4-max 的上下文长度为 1M Token;非思考模式最大输出 131,072 Token,思考与最终回答合计最大 262,144 Token;默认 reasoning_effort=high,thinking_budget=131072。
gateway.auth.mode: none 仅适合单机本地使用。需要共享或远程访问时,运行 openclaw doctor --generate-gateway-token 生成 token,再重启 Gateway。

接入消息渠道

  • 钉钉
  • 飞书
  • 微信
  • QQ
  • 邮箱
使用轻量应用服务器或无影云电脑部署 OpenClaw 时,通常已内置钉钉插件,并可通过图形化界面完成配置。
  1. 1

    创建钉钉应用并获取凭证

    1. 登录钉钉开放平台,选择有开发者权限的组织,或创建组织后获取开发者权限。
    2. 在顶部菜单栏选择应用,点击创建应用,填写应用名称和描述后点击保存。
    3. 在添加应用能力页面添加机器人,开启机器人配置,填写必填项,消息接收模式保持默认的 Stream 模式,点击发布。
    4. 在凭证与基础信息页面获取 Client ID 和 Client Secret。
    5. 在版本管理与发布页面创建版本,设置可见范围,保存并发布。
  2. 2

    安装钉钉渠道插件

    openclaw plugins install @soimy/dingtalk
    openclaw plugins list
    
    输出中应包含 dingtalk 插件且状态为 loaded。
  3. 3

    配置钉钉渠道

    在 ~/.openclaw/openclaw.json 中添加以下配置。将 YOUR_DINGTALK_APPKEY 和 YOUR_DINGTALK_APPSECRET 替换为步骤一获取的凭证,不要覆盖已有的 models、agents 等配置。
    {
      "channels": {
        "dingtalk": {
          "enabled": true,
          "clientId": "YOUR_DINGTALK_APPKEY",
          "clientSecret": "YOUR_DINGTALK_APPSECRET",
          "robotCode": "YOUR_DINGTALK_APPKEY",
          "dmPolicy": "open",
          "groupPolicy": "open",
          "messageType": "markdown"
        }
      },
      "plugins": {
        "allow": ["dingtalk"],
        "entries": {
          "dingtalk": {
            "enabled": true
          }
        }
      }
    }
    
    dmPolicy 和 groupPolicy 设为 open 适用于测试或个人使用。生产环境建议改为 allowlist,并添加 allowFrom 字段:
    "dmPolicy": "allowlist",
    "groupPolicy": "allowlist",
    "allowFrom": ["你的工号", "群ID"]
    
  4. 4

    验证

    openclaw gateway restart
    openclaw status
    
    在 Channels 部分,DingTalk 应显示为 ON,状态为 OK - configured。在钉钉群聊中向机器人发送消息测试。

错误码

配置过程中遇到报错,参考对应计费方案的常见问题文档:

常见问题

按量计费接入方式不变,使用百炼通用 API Key 和 Base URL。购买节省计划或资源包后自动生效,调用费用按抵扣顺序自动抵扣。详情参见节省计划与资源包。
在终端输入 openclaw tui,进入 OpenClaw 终端命令行,接着输入 /model 查看模型列表。按回车键选中模型,按 Esc 键退出模型列表。
可能原因:
  1. API Key 无效、过期、为空、格式错误,或与端点环境不匹配。请检查 API Key 是否与所使用的付费方式匹配,并确保复制完整且无空格;确认订阅状态有效。
  2. OpenClaw 的历史配置缓存导致配置错误,请删除 ~/.openclaw/agents/main/agent/models.json 文件中的 providers 配置项,并重启 OpenClaw。
  3. invalid_iam_token 表示 API Key 经 IAM 鉴权校验失败。常见场景:API Key 已被吊销或禁用、API Key 归属的地域与 Base URL 所指地域不一致(例如 API Key 在华北2(北京),但 Base URL 指向其他地域)、使用 STS 临时凭证且已过期。请核对 API Key 与 Base URL 归属同一地域,并确认 API Key 状态正常。
  • 不要直接全量覆盖。全量替换会覆盖自定义配置,请进行局部修改。
  • 若 OpenClaw 可正常对话,直接在 OpenClaw 对话中输入指令完成配置合并。
  • 若 OpenClaw 未配置模型或无法对话,手动编辑 ~/.openclaw/openclaw.json,只修改需要变更的字段,保留原有配置不变。
重启网关后,已有会话可能无法正常对话,请重启会话。
详细报错信息:
http://127.0.0.1:18791/15:05:56 [ws] closed before connect conn=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx remote=127.0.0.1 fwd=n/a origin=n/a host=127.0.0.1:18789 ua=n/a code=1008 reason=device identity required
原因:客户端连接网关时未提供设备身份信息,通常由以下原因导致:
  • 首次打开浏览器访问地址,尚未完成设备配对。
  • 浏览器缓存被清除,设备密钥丢失。
  • 重装或升级 OpenClaw 后,~/.openclaw/identity/ 目录下的密钥文件缺失。
解决方法:在终端执行以下命令,允许当前设备连接并重新生成浏览器访问地址:
openclaw devices approve --latest
openclaw dashboard --no-open
如果仍未解决,先清除异常的设备记录再重试:
openclaw devices clear --pending --yes
openclaw dashboard --no-open
执行 openclaw devices list,确认设备显示在 Paired 列表中即为正常。
原因: OpenClaw 内置心跳机制(Heartbeat),网关运行期间会按固定间隔(默认 30 分钟)自动调用已配置的模型,检查是否有待处理任务。每次心跳都会消耗少量 Token。如何确认: 查看 ~/.openclaw/agents/main/sessions/ 目录下的会话记录文件(.jsonl),其中包含 [OpenClaw heartbeat poll] 标记的心跳调用记录。解决方法:
  • 停止网关:不使用时执行 openclaw gateway stop,心跳随即停止。
  • 增大心跳间隔:在 ~/.openclaw/openclaw.json 中设置 agents.defaults.heartbeat.every,例如 "2h" 表示每 2 小时一次。