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.ap-southeast-1.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.4",
                "name": "glm-5.4",
                "reasoning": true,
                "input": [
                  "text",
                  "image"
                ],
                "contextWindow": 1048576,
                "maxTokens": 131072,
                "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 在新加坡,但 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 小時一次。