Skip to content
All use cases
OpenCode

Run OpenCode through AnyRouter

One CLI command injects an AnyRouter provider for the session, or add a custom provider in opencode.json — one key, the Chat Completions catalog, and request logs.

01

The problem

What this is for

OpenCode's built-in providers each want their own key. Switching models or sharing billing with Claude Code and Codex means editing every tool separately.

02

What to do

Three steps, then copy

  1. 1.Create an AnyRouter key in the dashboard (sk-ar-…), or let the CLI sign you in.
  2. 2.Launch with anyr opencode so it injects the provider for that session, or add AnyRouter to opencode.json for a persistent config.
  3. 3.Pick an anyrouter/… model in /models and confirm the call in request logs.
anyr launcher
bash
anyr opencode
opencode.json
json
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "anyrouter": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "AnyRouter",
      "options": {
        "baseURL": "https://anyrouter.dev/api/v1",
        "apiKey": "{env:ANYROUTER_API_KEY}"
      },
      "models": {
        "anthropic/claude-sonnet-4.6": {
          "name": "Claude Sonnet 4.6"
        }
      }
    }
  },
  "model": "anyrouter/anthropic/claude-sonnet-4.6"
}

Ready to try it

The guide has the full walkthrough. Sign up if you still need a key.