B2BB2B LLM

OpenCode

Configure OpenCode with a Model Gate OpenAI-compatible provider.

OpenCode through Model Gate

For current OpenCode versions, use an OpenAI-compatible custom provider.

Configuration path

SystemPath
Windows%USERPROFILE%\.config\opencode\opencode.jsonc
Linux or macOS~/.config/opencode/opencode.jsonc

Environment variable

Linux or macOS

export MODEL_GATE_API_KEY="mg_live_..."

Windows PowerShell

$env:MODEL_GATE_API_KEY = "mg_live_..."

Configuration

{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "model_gate": {
      "name": "Model Gate",
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://api.model-gate.com/v1",
        "apiKey": "{env:MODEL_GATE_API_KEY}"
      },
      "models": {
        "ch-47": {
          "name": "Claude Opus 4.7 through Model Gate"
        }
      }
    }
  },
  "model": "model_gate/ch-47"
}

Use @ai-sdk/openai instead when a selected OpenCode workflow specifically requires the Responses API rather than Chat Completions.

Start

opencode

Troubleshooting

ProblemResolution
Provider is missingConfirm the provider ID in the model name matches model_gate.
Authentication failsConfirm the environment variable is present before starting OpenCode.
Wrong endpointUse https://api.model-gate.com/v1.
Model not foundUse an enabled canonical model or alias.
Config validation failsCheck the installed OpenCode documentation because provider schema can change between versions.

Current provider documentation: https://opencode.ai/docs/providers.