> ## Documentation Index
> Fetch the complete documentation index at: https://docs.aihubmix.com/llms.txt
> Use this file to discover all available pages before exploring further.

# OpenClaw

## 安裝

<Note>
  安裝前請確認 Node >= 22。
</Note>

執行安裝指令

```shellscript theme={null}
npm install -g openclaw@latest
```

安裝完成後，後續命令可以在任意目錄執行，不需要先切換到 OpenClaw 安裝目錄。如果終端機能識別 `openclaw`，直接複製文件中的命令即可。

```powershell theme={null}
openclaw models status
```

如果 Windows 終端機提示找不到 `openclaw`，請把命令開頭的 `openclaw` 替換成本機可執行檔路徑：

```powershell theme={null}
& "你的安裝路徑\OpenClaw\openclaw.cmd" models status
```

<Note>
  `你的安裝路徑` 是佔位符，請替換為你實際安裝 OpenClaw 的上層目錄。例如 OpenClaw 位於 `D:\Apps\OpenClaw` 時，應寫成 `& "D:\Apps\OpenClaw\openclaw.cmd" models status`。
</Note>

### 終端機設定

開啟終端機並執行下列指令以啟動設定

```shellscript theme={null}
openclaw onboard
```

選擇 `Yes`

<img src="https://mintcdn.com/aihubmix/WotSdjzuAai7hVOs/public/cn/oc-1.png?fit=max&auto=format&n=WotSdjzuAai7hVOs&q=85&s=88d5674d5255b84d695044b7e36fbfcc" alt="Oc 1" width="1212" height="814" data-path="public/cn/oc-1.png" />

選擇 `QuickStart`

<img src="https://mintcdn.com/aihubmix/WotSdjzuAai7hVOs/public/cn/oc-2.png?fit=max&auto=format&n=WotSdjzuAai7hVOs&q=85&s=093443c0dc408dfaa6b6b4eba004e8d1" alt="Oc 2" width="1212" height="814" data-path="public/cn/oc-2.png" />

選擇 `Skip for now`

<img src="https://mintcdn.com/aihubmix/WotSdjzuAai7hVOs/public/cn/oc-3.png?fit=max&auto=format&n=WotSdjzuAai7hVOs&q=85&s=690bbdc272c9e3de0eec7fb3bb65ca93" alt="Oc 3" width="1212" height="814" data-path="public/cn/oc-3.png" />

選擇 `All providers`

<img src="https://mintcdn.com/aihubmix/WotSdjzuAai7hVOs/public/cn/oc-4.png?fit=max&auto=format&n=WotSdjzuAai7hVOs&q=85&s=03c0af702000f97a0c53470300f0f3a7" alt="Oc 4" width="1212" height="814" data-path="public/cn/oc-4.png" />

依需求選擇預設模型；您可以先選擇 `Keep current`（如使用「方法 2：手動設定」，後續步驟可在設定檔中修改）。

<img src="https://mintcdn.com/aihubmix/WotSdjzuAai7hVOs/public/cn/oc-5.png?fit=max&auto=format&n=WotSdjzuAai7hVOs&q=85&s=996d39a888f2f5b739dbfc8bcc0f033f" alt="Oc 5" width="1212" height="814" data-path="public/cn/oc-5.png" />

依需求連結您的個人帳戶；如不需要，請選擇 `Skip for now`。

<img src="https://mintcdn.com/aihubmix/WotSdjzuAai7hVOs/public/cn/oc-6.png?fit=max&auto=format&n=WotSdjzuAai7hVOs&q=85&s=28b73573f717822c0786788c582aa99e" alt="Oc 6" width="1212" height="814" data-path="public/cn/oc-6.png" />

設定技能時請選擇 `Yes`。

<img src="https://mintcdn.com/aihubmix/WotSdjzuAai7hVOs/public/cn/oc-7.png?fit=max&auto=format&n=WotSdjzuAai7hVOs&q=85&s=fe9c36aac91dd294ccce4a1ee12ad0e0" alt="Oc 7" width="1212" height="814" data-path="public/cn/oc-7.png" />

選擇 `npm`

<img src="https://mintcdn.com/aihubmix/WotSdjzuAai7hVOs/public/cn/oc-8.png?fit=max&auto=format&n=WotSdjzuAai7hVOs&q=85&s=c6eef11c88ae8f783e8d12bd196bdd0c" alt="Oc 8" width="1212" height="814" data-path="public/cn/oc-8.png" />

依需求設定技能選擇。

<img src="https://mintcdn.com/aihubmix/WotSdjzuAai7hVOs/public/cn/oc-9.png?fit=max&auto=format&n=WotSdjzuAai7hVOs&q=85&s=0ae533bdae76daf8939f91acc8df90dc" alt="Oc 9" width="1212" height="814" data-path="public/cn/oc-9.png" />

所有選項皆選擇 `No`。

<img src="https://mintcdn.com/aihubmix/WotSdjzuAai7hVOs/public/cn/oc-10.png?fit=max&auto=format&n=WotSdjzuAai7hVOs&q=85&s=30834a010846ee0b3f53e13770346bca" alt="Oc 10" width="1212" height="814" data-path="public/cn/oc-10.png" />

選擇 `Skip for now`。

<img src="https://mintcdn.com/aihubmix/WotSdjzuAai7hVOs/public/cn/oc-11.png?fit=max&auto=format&n=WotSdjzuAai7hVOs&q=85&s=1473f71f42c750cf132f321f9b4bc5bb" alt="Oc 11" width="1212" height="814" data-path="public/cn/oc-11.png" />

選擇 `Hatch in UI`。

## 設定 AIHubMix

### 方法 1:透過外掛快速設定(推薦)

<Info>
  外掛原始碼：[aihubmix-auth](https://github.com/akakenle/aihubmix-auth)
</Info>

安裝 AIHubMix auth 外掛並重新啟動 Gateway:

```shellscript theme={null}
openclaw plugins install @akakenle/aihubmix-auth
openclaw gateway restart
```

執行 auth 指令。在提示時輸入您的 AIHubMix API Key。只需對四個 provider 任選其一執行一次以下指令即可——外掛透過 `providerAuthAliases` 讓同一把 key 同時生效到全部 transport：

```shellscript theme={null}
openclaw models auth login --provider aihubmix-openai --method api-key --set-default
```

外掛會將模型分為以下群組：

* **aihubmix-openai** — `gpt-*` / `o1-*` / `o3-*` / `o4-*`，`https://aihubmix.com/v1`（`openai-completions`）
* **aihubmix-anthropic** — `claude-*`，`https://aihubmix.com`（`anthropic-messages`）
* **aihubmix-google** — `gemini-*`，`https://aihubmix.com/gemini/v1beta`（`google-generative-ai`）
* **aihubmix-other** — 其他模型，`https://aihubmix.com/v1`（`openai-completions`）

簡寫 id（如 `claude-sonnet-4-5`）會由外掛的 `resolveDynamicModel` hook 自動路由到對應 transport，不需要寫完整 `provider/model`。

> 不想走互動式登入：先 `export AIHUBMIX_API_KEY=sk-...` 再 install，外掛會把 key 作為 inline `apiKey` 寫入 provider 設定（互動式登入則由 SDK 存入 auth-profile）。

設定完成後，跳轉至[啟動](#啟動)區段即可開始使用。

### 方法 2:手動設定

開啟 `~/.openclaw/openclaw.json` 檔案並加入下列設定：

```json theme={null}
{
  "models": {
    "mode": "merge",
    "providers": {
      "aihubmix-openai": {
        "baseUrl": "https://aihubmix.com/v1",
        "api": "openai-completions",
        "models": [
          {
            "id": "gpt-4o",
            "name": "gpt-4o",
            "reasoning": false,
            "input": ["text"],
            "cost": {
              "input": 0,
              "output": 0,
              "cacheRead": 0,
              "cacheWrite": 0
            },
            "contextWindow": 128000,
            "maxTokens": 16384
          }
        ]
      },
      "aihubmix-anthropic": {
        "baseUrl": "https://aihubmix.com",
        "api": "anthropic-messages",
        "models": [
          {
            "id": "claude-sonnet-4-5",
            "name": "claude-sonnet-4-5",
            "reasoning": false,
            "input": ["text"],
            "cost": {
              "input": 0,
              "output": 0,
              "cacheRead": 0,
              "cacheWrite": 0
            },
            "contextWindow": 200000,
            "maxTokens": 64000
          }
        ]
      },
      "aihubmix-google": {
        "baseUrl": "https://aihubmix.com/gemini/v1beta",
        "api": "google-generative-ai",
        "models": []
      },
      "aihubmix-other": {
        "baseUrl": "https://aihubmix.com/v1",
        "api": "openai-completions",
        "models": []
      }
    }
  },
  "agents": {
    "defaults": {
      "model": {
        "primary": "aihubmix-anthropic/claude-sonnet-4-5"
      },
      "workspace": "your_workspace_path",
      "compaction": {
        "mode": "safeguard"
      },
      "maxConcurrent": 4,
      "subagents": {
        "maxConcurrent": 8
      }
    }
  }
}
```

### 方法 3：使用動態模型命令切換預設模型

AIHubMix OpenClaw 外掛支援動態模型路由。只要模型在你的 AIHubMix 帳號中可用，就可以按 `provider/model-id` 的格式直接呼叫；模型可用性以 AIHubMix 控制台和 API 實際返回為準。

常用 provider 選擇規則如下：

* `aihubmix-openai`：OpenAI 相容模型，例如 `gpt-*`、`o1-*`、`o3-*`、`o4-*`
* `aihubmix-anthropic`：Claude 模型，例如 `claude-*`
* `aihubmix-google`：Gemini 模型，例如 `gemini-*`
* `aihubmix-other`：其他透過 OpenAI 相容介面呼叫的模型，例如 `glm-5.2`

下面以將 `gpt-5.4` 設定為 OpenClaw 預設模型為例：

```powershell theme={null}
openclaw models set aihubmix-openai/gpt-5.4
```

如果 Windows 終端機提示找不到 `openclaw`，使用本機路徑寫法：

```powershell theme={null}
& "你的安裝路徑\OpenClaw\openclaw.cmd" models set aihubmix-openai/gpt-5.4
```

查看目前預設模型和認證狀態：

```powershell theme={null}
openclaw models status
```

真實呼叫測試：

```powershell theme={null}
openclaw infer model run --local --json --model aihubmix-openai/gpt-5.4 --prompt "只回覆 OK"
```

如果需要呼叫非 OpenAI / Claude / Gemini 分組的模型，可使用 `aihubmix-other`，例如：

```powershell theme={null}
openclaw infer model run --local --json --model aihubmix-other/glm-5.2 --prompt "只回覆 OK"
```

查看 OpenClaw 目前已載入的模型目錄：

```powershell theme={null}
openclaw infer model list --json
```

## 啟動

```shellscript theme={null}
openclaw gateway
```

## 測試

在聊天頁面輸入 `hello`；若收到回覆，即代表設定成功。

<img src="https://mintcdn.com/aihubmix/WotSdjzuAai7hVOs/public/cn/oc-12.png?fit=max&auto=format&n=WotSdjzuAai7hVOs&q=85&s=3340254888707f81142e23906a55ff0e" alt="Oc 12" width="3266" height="1892" data-path="public/cn/oc-12.png" />

## 常見問題

### 版本升級

```shellscript theme={null}
openclaw plugins update @akakenle/aihubmix-auth
openclaw gateway restart
```

### Gateway 處理程序被佔用

```shellscript theme={null}
openclaw gateway stop
openclaw gateway
```

***

最後更新：2026-07-03
