Skip to content

OpenCode Configuration Guide: Connect to the NextHub API ​

OpenCode is a terminal-based AI coding tool that supports multiple models. Below are the steps for connecting to NextHub's Claude channel.

Setup Steps ​

1. Install OpenCode ​

Make sure Node.js is installed, then install OpenCode globally:

bash
npm i -g opencode-ai

After installation, run it once so it generates the default configuration folder:

bash
opencode

2. Open the OpenCode configuration folder ​

bat
start "" "%USERPROFILE%\.config\opencode"
bash
open "$HOME/.config/opencode"

3. Edit opencode.json — Add the Claude configuration ​

Find opencode.json in the configuration folder (create it if it doesn't exist), and fill in your ApiKey and the NextHub endpoint under provider.anthropic.options following the official OpenCode schema:

json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "anthropic": {
      "options": {
        "apiKey": "your NextHub ApiKey",
        "baseURL": "https://api.nexthub.cc"
      }
    }
  }
}

Don't add /v1 to the Base URL

OpenCode automatically appends /v1/messages to the baseURL, so just use the bare domain https://api.nexthub.cc here — don't add /v1 at the end.

4. Verify the configuration ​

Run opencode, enter the /models command, and you're set if Claude models show up in the list:

bash
opencode
# run after entering the interactive interface
# /models

Connecting to the GPT Channel as Well ​

Add an openai provider to the same opencode.json to use the GPT / Codex model families:

json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "anthropic": {
      "options": {
        "apiKey": "your NextHub ApiKey",
        "baseURL": "https://api.nexthub.cc"
      }
    },
    "openai": {
      "options": {
        "apiKey": "your NextHub ApiKey",
        "baseURL": "https://api.nexthub.cc/v1"
      }
    }
  }
}

The Two Base URLs Follow Different Conventions

anthropic uses the Anthropic protocol, so baseURL takes the bare domain https://api.nexthub.cc (/v1/messages is appended automatically); openai uses the OpenAI-compatible protocol, so baseURL must include /v1. Choose the matching group for each of the two ApiKeys (a Claude group and the GPT-Azure / GPT-Pro group). You can also use the same key for both — but the group determines which models are available, so configuring them separately is usually clearer.

NextHub · Direct connections to OpenAI / Anthropic via official account pools — reliable, secure, and worry-free.