> ## 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.

# Use in OpenCode

> Connect HubTo to OpenCode through a custom OpenAI-compatible provider.

## Overview

OpenCode lets you configure custom model providers through its config file.

With HubTo, you can route OpenCode requests through a single gateway and manage API keys, models, and quotas in one place.

## Quick setup

Set your API key:

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

Create or update `~/.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"
}
```

Then start OpenCode:

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

## Notes

* Use `https://api.hubto.ai/v1` as the base URL.
* You can switch models by updating `model` to values like `hubto/deepseek-v3.1`.
* You can also put `opencode.json` in a project root if you want per-project config.
