Wire OpenCode up to Gab AI as a custom OpenAI-compatible provider via opencode.json.
OpenCode does not pick up OPENAI_BASE_URL or OPENAI_API_KEY for custom endpoints — you have to declare Gab AI as a provider in opencode.json (project-local) or ~/.config/opencode/opencode.json (global) using the @ai-sdk/openai-compatible package. Each model you want to use must be listed under models with its Gab AI slug as the key. OpenCode stores credentials separately from the config file (in ~/.local/share/opencode/auth.json). After saving the config above:
The keys under models must exactly match slugs returned by GET /v1/models — they're lowercase, hyphenated, and use no dots. "Claude Opus 4.7", "claude opus", or "claude_opus" all return 400 invalid_model.
Tool/function calling is required for OpenCode's agent loop. List Gab AI's function-calling models with: Add any of those slugs to the models map in your opencode.json to make them selectable in /models.
Capture the exact request body and response from OpenCode's debug output. Most setup issues come down to (a) a model slug typo, (b) a model without function calling, or (c) the custom-provider-options bug above.
{
"$schema": "https://opencode.ai/config.json",
"provider": {
"gab-ai": {
"npm": "@ai-sdk/openai-compatible",
"name": "Gab AI",
"options": {
"baseURL": "https://gab.ai/v1"
},
"models": {
"arya": { "name": "Arya" },
"claude-opus-4-7": { "name": "Claude Opus 4.7" },
"claude-opus-4-8": { "name": "Claude Opus 4.8" },
"claude-sonnet-4-5":{ "name": "Claude Sonnet 4.5" },
"gpt-5-5": { "name": "GPT-5.5" },
"gpt-5-3-codex": { "name": "GPT-5.3 Codex" },
"gemini-3-5-flash": { "name": "Gemini 3.5 Flash" },
"qwen-3-5-397b": { "name": "Qwen 3.5 397B" },
"minimax-m2-7": { "name": "MiniMax M2.7" }
}
}
}
}
The keys under models must exactly match slugs returned by GET /v1/models — they're lowercase, hyphenated, and use no dots. "Claude Opus 4.7", "claude opus", or "claude_opus" all return 400 invalid_model.
curl https://gab.ai/v1/models \\
-H "Authorization: Bearer YOUR_GAB_API_KEY" \\
| jq -r '.data[] | select(.capabilities.function_calling and .capabilities.text) | .id'
Capture the exact request body and response from OpenCode's debug output. Most setup issues come down to (a) a model slug typo, (b) a model without function calling, or (c) the custom-provider-options bug above.