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
- macOS / Linux (curl)
- Homebrew
- Windows
2
Register the Custom Provider
Before editing the configuration file, you must first register a custom provider using the OpenCode CLI:When prompted:
- Select “other” as the provider type.
- Enter
foxapias the provider ID. - Enter any placeholder value for the token (it will be overridden in the config file).
3
Configure AihubMax
Edit the OpenCode configuration file:Set the contents to the following:Replace
- macOS / Linux
- Windows
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:
Recommended Models
Troubleshooting
Provider not recognized
Provider not recognized
- Make sure you have run
opencode auth loginand registered thefoxapiprovider 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.
Authentication failed
Authentication failed
- Verify your AihubMax API key is correct in the
options.apiKeyfield. - Ensure the key has sufficient balance and model access.
Configuration file not found
Configuration file not found
- 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.
Models not showing up
Models not showing up
- Use the
/modelscommand inside OpenCode to check available models. - Verify that the
modelssection in your config lists the correct model IDs. - Ensure the
baseURLis set tohttps://api.aihubmax.com/v1.