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 FoxAPI, you can access a variety of AI models through a single API endpoint.OpenCode supports custom providers via its JSON configuration, making FoxAPI integration straightforward.
Prerequisites
FoxAPI API Key
An active FoxAPI API key.
OpenCode
OpenCode installed on your system.
Installation & Configuration
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).
Configure FoxAPI
Edit the OpenCode configuration file:Set the contents to the following:Replace
- macOS / Linux
- Windows
sk-your-foxapi-api-key with your actual FoxAPI API key.Verify the Connection
After launching OpenCode, use the/models command inside the TUI to verify that the configured models are available:
Recommended Models
| Use Case | Model | Description |
|---|---|---|
| Complex Tasks | claude-opus-4-20250514 | Best for complex reasoning and architecture |
| Balanced | claude-sonnet-4-20250514 | Great balance of quality and speed |
| Fast & Efficient | gpt-4o | Quick responses for everyday tasks |
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 FoxAPI 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.foxapi.cc/v1.