Configure Gab AI in OpenCode v1 or v2 with the OpenAI-compatible Responses API.
Declare Gab AI as a custom provider in opencode.json or opencode.jsonc in your project, or in ~/.config/opencode/opencode.json for global use. Set the base URL to https://gab.ai/v1. The provider package selects the API protocol; choose the Responses adapter for the setup below.
@ai-sdk/openai selects /v1/responses in OpenCode v1. For OpenCode v2, this guide uses @opencode/ai/providers/openai/responses with a custom base URL as a workaround for the generic Responses adapter loading issue. The plain @ai-sdk/openai-compatible and @opencode/ai/providers/openai-compatible adapters select /v1/chat/completions, which Gab AI also supports. They use a different protocol from the Responses examples in this guide. The package choice does not guarantee a fixed credit charge per tool turn; text requests with reliable usage settle in fractional credits based on usage.
GET https://gab.ai/v1/agent-setup?client=opencode currently generates a v1 configuration with @ai-sdk/openai, live model limits, modalities and tool_call flags. Save the generated config to a separate file, then merge its Gab AI provider entry into your existing config. For a new config, you can use the generated file directly. Use auto only for the main agent model; use a concrete model slug for auxiliary calls.
curl -fsSL "https://gab.ai/v1/agent-setup?client=opencode" | jq .config > gab-opencode-v1.json
{
"$schema": "https://opencode.ai/config.json",
"model": "gab-ai/claude-sonnet-4-5",
"provider": {
"gab-ai": {
"npm": "@ai-sdk/openai",
"name": "Gab AI",
"options": {
"baseURL": "https://gab.ai/v1"
},
"models": {
"claude-sonnet-4-5": {
"name": "Claude Sonnet 4.5",
"limit": {
"context": 200000,
"output": 64000
},
"modalities": {
"input": [
"text",
"image"
],
"output": [
"text"
]
},
"tool_call": true
}
}
}
}
}
OpenCode issue #49670 reports that @opencode/ai/providers/openai-compatible/responses is missing from the bundled provider registry, causing Cannot find package '@opencode/ai' during initialization before a request reaches Gab AI. The issue remained open when checked on October 4, 2026, with reproduction reported on v2.0.20. The example below uses @opencode/ai/providers/openai/responses with https://gab.ai/v1 as the upstream-reported workaround; this workaround has not been independently verified against Gab AI. Alternatively, use @opencode/ai/providers/openai-compatible for /v1/chat/completions, which Gab AI also supports. Removing /responses changes the API protocol.
Use the plural providers map, package and settings fields shown below. This example uses GAB_API_KEY for the credential; set it in the environment of the OpenCode server, or connect Gab AI through /connect. Save or merge the example into your config, then use /models to select a Gab AI model. The model limits below are an example from the live catalog; recheck /v1/models when adding or changing models.
{
"$schema": "https://opencode.ai/config.json",
"model": "gab-ai/claude-sonnet-4-5",
"providers": {
"gab-ai": {
"name": "Gab AI",
"env": [
"GAB_API_KEY"
],
"package": "@opencode/ai/providers/openai/responses",
"settings": {
"baseURL": "https://gab.ai/v1"
},
"models": {
"claude-sonnet-4-5": {
"name": "Claude Sonnet 4.5",
"limit": {
"context": 200000,
"output": 64000
},
"capabilities": {
"tools": true,
"input": [
"text",
"image"
],
"output": [
"text"
]
}
}
}
}
}
}
Do not paste the generated /v1/agent-setup config unchanged into a native v2 setup. Rename provider to providers, replace npm with package: "@opencode/ai/providers/openai/responses", and move options to settings. Keep each model's name and limit. Replace tool_call and modalities with capabilities.tools, capabilities.input and capabilities.output, as shown in the v2 example.
Use a model ID from /v1/models or an alias listed by that endpoint. The provider prefix is gab-ai, so the selectable model reference in the examples is gab-ai/claude-sonnet-4-5. Display names are labels, not API model IDs.
Tool/function calling is required for OpenCode's agent loop. GET /v1/models is public and includes context_window, max_output_tokens, capabilities.function_calling and recommended_for. Match each model's OpenCode limits and tool/media capabilities to those values. In v1 use tool_call and modalities; in v2 use capabilities.tools, capabilities.input and capabilities.output.
curl -fsSL https://gab.ai/v1/models | jq -r ' .data[] | select(.capabilities.function_calling == true) | select(any(.recommended_for[]?; . == "coding")) | .id'