Skip to content
All use cases

OpenCodeCoding agents

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.

Set it up

anyr launcher
$ curl -fsSL https://anyrouter.dev/cli.sh | bash$ anyr loginSigned in.  via browser  key sk-ar-v1-7f3c2…9a1dSaved  /Users/you/.anyrouter/config.yamlNext  anyr claude$ anyr opencode
  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.
Why use this

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.

Other ways to set it up
opencode.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"
}
Endpoints and key
OpenAI-compatible
https://anyrouter.dev/api/v1
Anthropic-compatible
https://anyrouter.dev/api
Key
ANYROUTER_API_KEY (sk-ar-…)
Watch the walkthrough
Limits
  • anthropic/* models in the example run on your own Anthropic key (BYOK). Swap in any listed model id to use credits.