OpenCode Integration
OpenCode is an open-source terminal AI coding tool. Fusion AI Gateway provides OpenAI-compatible endpoints (/v1/chat/completions and /v1/models), so you can connect OpenCode directly to Fusion AI models.
Prerequisites
- An active Fusion API Key (
fc_...). See API Keys for details on generating a key. - OpenCode CLI or VS Code Extension installed.
1. Quick Environment Variable Setup
The fastest way to configure OpenCode (or any OpenAI-compatible tool) is by setting environment variables in your shell profile (~/.zshrc, ~/.bashrc, or ~/.config/fish/config.fish):
export OPENAI_BASE_URL="https://api.fusioncode.app/v1"
export OPENAI_API_KEY="fc_your_api_key_here"Apply the changes to your active terminal session:
source ~/.zshrcOnce exported, launch OpenCode (or OpenCode v2):
# OpenCode v2
opencode2 --model MiniMaxAI/MiniMax-M2.7
# OpenCode v1
opencode --model MiniMaxAI/MiniMax-M2.72. OpenCode Config File (opencode.json)
For project-level or global persistence, configure Fusion as a custom provider in your OpenCode configuration file (~/.config/opencode/opencode.json or ./opencode.json):
OpenCode v2 (Native Schema)
{
"$schema": "https://opencode.ai/config.json",
"model": "fusion/MiniMaxAI/MiniMax-M2.7",
"providers": {
"fusion": {
"package": "aisdk:@ai-sdk/openai-compatible",
"settings": {
"apiKey": "fc_your_api_key_here",
"baseURL": "https://api.fusioncode.app/v1"
},
"models": {
"MiniMaxAI/MiniMax-M2.7": {
"name": "MiniMax M2.7 (Fusion Gateway)",
"limit": {
"context": 200000,
"output": 64000
}
},
"deepseek-ai/DeepSeek-V4-Flash-0731": {
"name": "DeepSeek V4 Flash (Fusion Gateway)",
"limit": {
"context": 128000,
"output": 32000
}
}
}
}
}
}OpenCode v1 (Legacy Schema)
{
"$schema": "https://opencode.ai/config.json",
"model": "fusion/deepseek-ai/DeepSeek-V4-Flash-0731",
"small_model": "fusion/deepseek-ai/DeepSeek-V4-Flash-0731",
"provider": {
"fusion": {
"options": {
"apiKey": "fc_your_api_key_here",
"baseURL": "https://api.fusioncode.app/v1"
},
"models": {
"deepseek-ai/DeepSeek-V4-Flash-0731": {
"name": "DeepSeek V4 Flash (Fusion Gateway)",
"limit": {
"context": 128000,
"output": 32000
}
},
"MiniMaxAI/MiniMax-M2.7": {
"name": "MiniMax M2.7 (Fusion Gateway)",
"limit": {
"context": 200000,
"output": 64000
}
}
}
}
}
}3. Supported Models
Fusion AI Gateway connects directly to the following high-performance models:
| Model ID | Description | Recommended Use |
|---|---|---|
deepseek-ai/DeepSeek-V4-Flash-0731 |
DeepSeek V4 Flash model | Ultra-fast coding, edits & deep reasoning |
MiniMaxAI/MiniMax-M2.7 |
MiniMax M2.7 flagship model | Coding, complex refactoring & multi-file reasoning |
4. Verifying Endpoint Compatibility
Verify your OpenCode integration by testing the chat completions endpoint directly via curl:
curl -X POST https://api.fusioncode.app/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer fc_your_api_key_here" \
-d '{
"model": "MiniMaxAI/MiniMax-M2.7",
"messages": [
{ "role": "user", "content": "Say hello from Fusion AI Gateway!" }
]
}'Response:
{
"id": "chatcmpl-12345",
"object": "chat.completion",
"created": 1752192000,
"model": "MiniMaxAI/MiniMax-M2.7",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Hello! Fusion AI Gateway is operational and connected."
},
"finish_reason": "stop"
}
]
}5. Troubleshooting & Diagnostics
- Rate Limit Exceeded (
429): Fusion Gateway applies rate limits based on your IP and API key. Retry after 15 seconds or upgrade your plan. - Insufficient Quota (
402): Check your remaining token balance usingcurl https://api.fusioncode.app/v1/usage -H "Authorization: Bearer fc_...". - Port Conflict (Local Development): If running local dev proxy, ensure Fusion API is listening on port
8000(http://localhost:8000/v1).