B2BB2B LLM

OpenCode

Konfigurera OpenCode med en Model Gate OpenAI-kompatibel leverantör.

OpenCode genom Model Gate

För nuvarande OpenCode versioner, använd en OpenAI-kompatibel anpassad leverantör.

Konfigurationsväg

SystemVäg
Windows%USERPROFILE%\.config\opencode\opencode.jsonc
Linux eller macOS~/.config/opencode/opencode.jsonc

Miljövariabel

Linux eller macOS

export MODEL_GATE_API_KEY="mg_live_..."

Windows PowerShell

$env:MODEL_GATE_API_KEY = "mg_live_..."

Konfiguration

{
  "$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"
}

Använda @ai-sdk/openai i stället när ett valt OpenCode-arbetsflöde specifikt kräver Responses API snarare än Chat-slutföranden.

Start

opencode

Felsökning

ProblemUpplösning
Leverantör saknasBekräfta att leverantörs-ID:t i modellnamnet matchar model_gate.
Autentisering misslyckasBekräfta att miljövariabeln finns innan du startar OpenCode.
Fel slutpunktAnvända https://api.model-gate.com/v1.
Modellen hittades inteAnvänd en aktiverad kanonisk modell eller alias.
Konfigurationsvalideringen misslyckasKontrollera den installerade OpenCode-dokumentationen eftersom leverantörsschemat kan ändras mellan versioner.

Aktuell leverantörsdokumentation: https://opencode.ai/docs/providers.