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

# 在 OpenCode 中使用

> 將 HubTo 接入 OpenCode，透過自訂 OpenAI 相容提供方使用統一模型網關。

## 概述

OpenCode 支援透過設定檔接入自訂模型提供方。

接入 HubTo 後，你可以用統一的 API Key、基礎地址與模型名稱完成編碼問答、重構與命令列協作。

## 快速設定

先設定 API Key：

```bash theme={null}
export HUBTO_API_KEY="YOUR_API_KEY"
```

建立或更新 `~/.config/opencode/opencode.json`：

```json theme={null}
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "hubto": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "HubTo",
      "options": {
        "baseURL": "https://api.hubto.ai/v1",
        "apiKey": "{env:HUBTO_API_KEY}"
      },
      "models": {
        "glm-5.1": {
          "name": "GLM-5.1"
        }
      }
    }
  },
  "model": "hubto/glm-5.1"
}
```

接著啟動 OpenCode：

```bash theme={null}
opencode
```

## 說明

* 基礎地址請使用 `https://api.hubto.ai/v1`
* 如需切換模型，可把 `model` 改成 `hubto/deepseek-v3.1` 等值
* 如果你想按專案隔離設定，也可以把 `opencode.json` 放在專案根目錄
