OpenCode setup

Add uRouter as an OpenAI-compatible connection.

Set your key

Create an inference key in your dashboard and set UROUTER_API_KEY in the shell that starts OpenCode. Keep the key out of your project configuration and version control.

export UROUTER_API_KEY="YOUR_UROUTER_KEY"

Configure OpenCode

For OpenCode V2, add this to opencode.jsonc in your project. Replace MODEL_ID with an exact uRouter text-model ID that has execution enabled for your account. The OpenAI-compatible package uses the chat API rather than Anthropic Messages.

{
  "$schema": "https://opencode.ai/config.json",
  "providers": {
    "urouter": {
      "name": "uRouter",
      "env": [
        "UROUTER_API_KEY"
      ],
      "package": "@opencode/ai/providers/openai-compatible",
      "settings": {
        "baseURL": "https://api.urouter.net/v1"
      },
      "models": {
        "MODEL_ID": {
          "name": "My uRouter model"
        }
      }
    }
  }
}

Choose the model

Start OpenCode from that shell, run /models and select your uRouter model. This configuration follows the current OpenCode V2 documentation; the client integration has not been tested end to end. For tool use, choose a model that lists tool support.