Skip to main content
Route every model call OpenCode makes through the Orq.ai AI Gateway by editing a single configuration file. Requests appear in Traces automatically.

Prerequisites

npm i -g opencode-ai

Setup

Edit ~/.config/opencode/opencode.json to add an Orq.ai provider:
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "orq": {
      "npm": "@ai-sdk/anthropic",
      "name": "Orq Router",
      "options": {
        "baseURL": "https://api.orq.ai/v3/anthropic/v1",
        "apiKey": "<ORQ_API_KEY>"
      },
      "models": {
        "anthropic/claude-sonnet-4-6": { "name": "Claude Sonnet 4.6" },
        "anthropic/claude-haiku-4-5":  { "name": "Claude Haiku 4.5" },
        "anthropic/claude-opus-4-7":   { "name": "Claude Opus 4.7" }
      }
    }
  }
}
Replace <ORQ_API_KEY> with an API key. Before launching OpenCode, clear any conflicting Anthropic environment variables:
unset ANTHROPIC_AUTH_TOKEN ANTHROPIC_BASE_URL ANTHROPIC_API_KEY
opencode

Troubleshooting

The baseURL in opencode.json is missing the /v1 suffix. Change it to:
https://api.orq.ai/v3/anthropic/v1
Conflicting environment variables override the config file. Run:
unset ANTHROPIC_AUTH_TOKEN ANTHROPIC_BASE_URL ANTHROPIC_API_KEY
opencode

Verification

Once configured, send a prompt in OpenCode. The response appears in the editor and the trace appears in Orq.ai Traces with the model identifier anthropic/claude-sonnet-4-6 (or whichever model was selected).