Set up OpenCode with CodeGateway

One config file, one copy, one test request. Keep your existing OpenAI-compatible workflow.

~/.config/opencode/opencode.json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "codegateway": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "CodeGateway",
      "options": {
        "baseURL": "https://api.codegateway.dev/v1",
        "apiKey": "sk-cg-YOUR_KEY"
      },
      "models": {
        "deepseek-v4-flash": {}
      }
    }
  },
  "model": "codegateway/deepseek-v4-flash"
}

Card payments supported. Usage is metered per request and shown in your dashboard.

Three steps to a working setup

  1. Paste the config above into ~/.config/opencode/opencode.json and replace sk-cg-YOUR_KEY with your key.
  2. Replace <model-id> with a model from https://api.codegateway.dev/v1/models — the list is live, so no id goes stale.
  3. Run opencode and pick the codegateway/<model-id> model; send one test message.
  4. Confirm the request appears in Dashboard → Usage, then top up if your credit is low.

FAQ

Why does the base URL end with /v1?

OpenCode talks to OpenAI-compatible endpoints through @ai-sdk/openai-compatible, which appends /chat/completions to the base URL. Without /v1 the request hits the wrong path and OpenCode reports the model as unavailable.

Why is the model id a placeholder?

Model ids rotate. GET /v1/models is the live catalog, so the page shows a placeholder instead of an id that may be retired next month.

Do I need a paid plan before testing?

No. Create an account, get a key, and the included credit is enough to send the first requests. Top up only when you keep using it.

What happens when my balance runs out?

Requests return a 402 insufficient_balance error with the top-up link and your remaining usage, so you never have to hunt for the billing page.

Keep going

OpenCode + CodeGateway Setup: One Config, One Test