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

# OpenCode

OpenCode now suporta major model families como GPT, Claude, DeepSeek, Gemini, and Qwen. For OpenCode usage scenarios, o seguinte models are recommended:

* `coding-minimax-m2.1-free`
* `coding-glm-4.7-free`
* `claude-sonnet-4-5`
* `gpt-5`
* `gpt-5-codex`

This document explains how to install, configure, and launch OpenCode on different operating systems, and how to integrate the AIHubMix API.

***

Before installation, ensure that your system meets o seguinte requirements:

* **Node.js ≥ 18.0.0**
* Optional package managers for your operating system:
  * macOS / Linux: `brew`
  * Arch Linux: `paru`
  * Windows: `choco`, `winget`, or `scoop`

***

## 1. Installing OpenCode

Escolha any of o seguinte installation methods based on your operating system and tooling preferences.

### 1. Install via Node.js

```bash theme={null}
# Quick install using a CURL script
curl -fsSL https://opencode.ai/install | bash

# Using NPM
npm install -g opencode-ai

# Using Bun
bun install -g opencode-ai

# Using PNPM
pnpm install -g opencode-ai

# Using Yarn
yarn global add opencode-ai
```

### 2. Install via Homebrew (macOS / Linux)

```bash theme={null}
brew install sst/tap/opencode
```

### 3. Install via Paru (Arch Linux)

```bash theme={null}
paru -S opencode-bin
```

### 4. Windows Installation

```bash theme={null}
# Chocolatey
choco install opencode

# WinGet
winget install opencode

# Scoop
scoop bucket add extras
scoop install extras/opencode

# Or install via NPM (Node.js required)
# Note: Administrator privileges are required
npm install -g opencode-ai
```

## 2. Launching and Logging in to OpenCode

After installation, follow the steps below to complete authentication and configuration.

### 1. Log in to OpenCode

Execute o seguinte command in your terminal:

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

### 2. Selecione the AI Provider

On the login screen, selecione **AiHubMix** as the model provider.

<img src="https://mintcdn.com/aihubmix/XeJJLFET_XPqNDov/public/en/opencode-1.jpg?fit=max&auto=format&n=XeJJLFET_XPqNDov&q=85&s=fbbe597b6ce890d5fa0ecf46ed3abf77" alt="Opencode 1" width="936" height="600" data-path="public/en/opencode-1.jpg" />

### 3. chave de API Authorization

Enter your AiHubMix chave de API on the OpenCode login page to complete authorization.

<img src="https://mintcdn.com/aihubmix/XeJJLFET_XPqNDov/public/en/opencode-2.jpg?fit=max&auto=format&n=XeJJLFET_XPqNDov&q=85&s=06043e1e8ba2d401a1e86f2c92ee8ab1" alt="Opencode 2" width="920" height="512" data-path="public/en/opencode-2.jpg" />

***

## 3. Using Models

### 1. Installation Verification

Execute o seguinte command to verify that OpenCode is installed and configured correctly:

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

<img src="https://mintcdn.com/aihubmix/XeJJLFET_XPqNDov/public/en/opencode-3.jpg?fit=max&auto=format&n=XeJJLFET_XPqNDov&q=85&s=12d0db106c8d2f0c692b9167ad9c0cdd" alt="Opencode 3" width="2750" height="1420" data-path="public/en/opencode-3.jpg" />

***

### 2. Selecione a Model

Type `/models`, search for `aihubmix`, and selecione the desired model.

<img src="https://mintcdn.com/aihubmix/XeJJLFET_XPqNDov/public/en/opencode-4.jpg?fit=max&auto=format&n=XeJJLFET_XPqNDov&q=85&s=4c0f9ae0764bc401215761846c7edac8" alt="Opencode 4" width="1982" height="1290" data-path="public/en/opencode-4.jpg" />

***

## 4. Using AiHubMix no OpenCode Desktop Client

1. Download the OpenCode desktop application: [https://opencode.ai/download](https://opencode.ai/download) .
2. Abra OpenCode and follow the steps:`/model` → `Connect provider` → search for `aihubmix` → enter sua chave de API → `Submit`.

   <img src="https://mintcdn.com/aihubmix/XeJJLFET_XPqNDov/public/en/opencode-5.jpg?fit=max&auto=format&n=XeJJLFET_XPqNDov&q=85&s=a8b5de9e4200adb9b17847ab6878e8f7" alt="Opencode 5" width="2552" height="1420" data-path="public/en/opencode-5.jpg" />
3. Não model selection panel, search for `aihubmix` and selecione the model you want to use.

   <img src="https://mintcdn.com/aihubmix/XeJJLFET_XPqNDov/public/en/opencode-6.jpg?fit=max&auto=format&n=XeJJLFET_XPqNDov&q=85&s=8b0e2107a35b656179154f6c99f56b76" alt="Opencode 6" width="2550" height="1422" data-path="public/en/opencode-6.jpg" />

***

<h2 id="custom-base-url">
  5. URL base personalizada
</h2>

Por padrão, o OpenCode envia as requisições da AIHubMix para `https://aihubmix.com/v1`. Se você precisar que as requisições passem por um gateway próprio, um proxy corporativo ou um nó de aceleração, é possível sobrescrever esse endereço por meio de `options.baseURL`, **sem precisar modificar o código-fonte do OpenCode nem reinstalá-lo**.

#### Passo 1: Abrir o arquivo de configuração

Abra `~/.config/opencode/opencode.json` (no Windows, `%USERPROFILE%\.config\opencode\opencode.json`).

#### Passo 2: Adicionar `options.baseURL`

Adicione `options.baseURL` no provider `aihubmix`. Basta incluir esse único campo: o OpenCode faz automaticamente um merge profundo com a configuração interna, então não é necessário reescrever o provider inteiro:

```json theme={null}
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "aihubmix": {
      "options": {
        "baseURL": "https://api.inferera.com"
      }
    }
  }
}
```

> **Observação**: o `baseURL` só precisa ir até o nível do domínio (por exemplo, `https://api.inferera.com`); o caminho é montado automaticamente pelo SDK. Não acrescente `/v1` por conta própria (como em `https://api.inferera.com/v1`), pois isso resultaria em `/v1/v1/` e causaria erro 404.

#### Passo 3: Reiniciar e verificar

Saia completamente do OpenCode e inicie-o novamente. Execute:

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

Na saída, em `provider.aihubmix.options.baseURL`, você deverá ver o endereço que informou.

| Campo             | Descrição                                                                                                                |
| ----------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `options.baseURL` | Endereço de requisição personalizado, com prioridade maior que o endereço padrão; basta informar até o nível do domínio. |

***

## 6. FAQ and Tips

* If a chave de API fails validation, log back into the AiHubMix Console and verify that the key is valid: [https://console.aihubmix.com/token](https://console.aihubmix.com/token)
* View the built-in help documentation: `opencode` → `/help`
* OpenCode official documentation: [https://opencode.ai/docs/](https://opencode.ai/docs/)

***

Última atualização: 2026-06-01
