Skip to content

OpenCode ​

OpenCode is an open-source command-line coding assistant. Through the OpenAI-compatible API it can use any CodingRouter text model.

Preparation ​

  1. Install OpenCode: npm install -g opencode-ai
  2. Create a token, choosing the group for the model you want to use (for example gpt for GPT, claude for Claude).

Configuration ​

Edit ~/.config/opencode/opencode.json (to use it in one project only, put opencode.json in the project root):

json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "codingrouter": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "CodingRouter",
      "options": {
        "baseURL": "https://api.codingrouter.ai/v1",
        "apiKey": "{env:CODINGROUTER_KEY}"
      },
      "models": {
        "gpt-5.5": { "name": "GPT-5.5" },
        "claude-sonnet-5-5": { "name": "Claude Sonnet 5.5" }
      }
    }
  }
}

List the models you want in models. The names must match the model square and the models must be in the token's group.

Set the token and start:

bash
export CODINGROUTER_KEY="sk-your-token"
opencode

After starting, use /models to select a model under CodingRouter.

Verify ​

bash
opencode run -m codingrouter/gpt-5.5 "Reply with exactly: CODINGROUTER OK"

Troubleshooting ​

SymptomWhat to do
HTML or 404 returnedbaseURL must include /v1
503The model name is wrong, or the token's group does not contain this model
Using models from several vendors in one configA token belongs to one group. Configure one provider per vendor, each with the token of the matching group