Skip to main content

Overview

OpenCode is a Go-based TUI (Terminal User Interface) coding assistant that works with multiple LLM providers. It provides an interactive terminal interface for chatting with AI about your code, generating changes, and running commands. By configuring OpenCode with AihubMax, you can access a variety of AI models through a single API endpoint.
OpenCode supports custom providers via its JSON configuration, making AihubMax integration straightforward.

Prerequisites

AihubMax API Key

An active AihubMax API key.

OpenCode

OpenCode installed on your system.

Installation & Configuration

1

Install OpenCode

Verify the installation:
2

Register the Custom Provider

Before editing the configuration file, you must first register a custom provider using the OpenCode CLI:
When prompted:
  1. Select “other” as the provider type.
  2. Enter foxapi as the provider ID.
  3. Enter any placeholder value for the token (it will be overridden in the config file).
This step is required. OpenCode will not recognize the foxapi provider in the configuration file unless it has been registered first via opencode auth login.
3

Configure AihubMax

Edit the OpenCode configuration file:
Set the contents to the following:
Replace sk-your-foxapi-api-key with your actual AihubMax API key.
4

Start Using OpenCode

Launch OpenCode in your project directory:
This opens the interactive TUI where you can chat with the AI about your codebase.

Verify the Connection

After launching OpenCode, use the /models command inside the TUI to verify that the configured models are available:
You should see the AihubMax models listed (e.g., Claude Sonnet 4, Claude Opus 4, GPT-4o). Then type a test message to confirm the connection:
A successful response confirms the AihubMax connection is active.

Troubleshooting

  • Make sure you have run opencode auth login and registered the foxapi provider before editing the config file.
  • Ensure the provider ID in the config matches exactly what you entered during registration.
  • Check that the configuration file syntax is valid JSON.
  • Verify your AihubMax API key is correct in the options.apiKey field.
  • Ensure the key has sufficient balance and model access.
  • On macOS/Linux, the config file should be at ~/.config/opencode/opencode.json.
  • On Windows, the config file should be at C:\Users\{username}\.config\opencode\opencode.json.
  • Use the /models command inside OpenCode to check available models.
  • Verify that the models section in your config lists the correct model IDs.
  • Ensure the baseURL is set to https://api.aihubmax.com/v1.