CloseRouter

OpenCode

Choose the connection format for your model. Configure both the provider and a model the agent can select.

1. Open the settings file

text
~/.config/opencode/opencode.json

2. Choose a connection

Use the first variant for the OpenAI-compatible API or the second for Claude through Messages. Replace YOUR_API_KEY. The baseURL ends in /v1, not /messages.

The models block populates the agent’s model picker. Context and output sizes in the example are client settings: check them against your selected provider in the catalog.

Configuration

JSON
{
  "$schema": "https://opencode.ai/config.json",
  "model": "closerouter/openai/gpt-5.4-mini",
  "provider": {
    "closerouter": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "CloseRouter",
      "options": {
        "baseURL": "https://api.closerouter.dev/v1",
        "apiKey": "YOUR_API_KEY"
      },
      "models": {
        "openai/gpt-5.4-mini": {
          "name": "GPT-5.4 Mini"
        }
      }
    }
  }
}

Check the connection

Save the file and restart the application. Select the configured CloseRouter model. If it is missing or the key is rejected, check the file location, API address and key.