Install OpenCode and Connect It to APITokenRouter

OpenCode is an open-source AI coding assistant that can run in terminal and desktop/web-style interfaces.

New accounts start with a $0 balance — top up before your first request. Top up from $5. If a request returns 402 with "wallet balance is insufficient", your balance is empty — your base URL and key are fine. Top up and retry.

1. Connect to APITokenRouter

If OpenCode Desktop is already installed, add APITokenRouter:

  1. Open OpenCode Desktop and click the settings icon in the lower-left corner.

  1. In the left navigation, choose Server -> Providers.
  2. At the bottom of the provider list, find Custom provider and click Connect.

  1. Fill in the custom provider form:
  • Provider ID: teamorouter
  • Display name: APITokenRouter
  • Base URL: https://apitokenrouter.com/v1
  • API key: paste the key you created in the APITokenRouter dashboard
  1. In Models, click Add model and add the model IDs you need.
Available model IDs37 models

OpenAIGPT9

  • gpt-6.1-sol
  • gpt-6-astra
  • gpt-6-sol
  • gpt-6-luna
  • gpt-5.6-sol
  • gpt-5.6-terra
  • gpt-5.6-luna
  • gpt-5.5
  • gpt-5.4

ClaudeClaude12

  • claude-opus-5-5
  • claude-sonnet-5-5
  • claude-haiku-5-5
  • claude-fable-5-1
  • claude-opus-5
  • claude-fable-5
  • claude-sonnet-5
  • claude-opus-4-8
  • claude-opus-4-7
  • claude-opus-4-6
  • claude-sonnet-4-6
  • claude-haiku-4-5

GeminiGemini5

  • gemini-3.8-flash
  • gemini-3.7-flash
  • gemini-3.6-flash
  • gemini-3.5-flash-lite
  • gemini-3.1-pro-preview

DeepSeekDeepSeek6

  • deepseek-flash
  • deepseek-flash-free
  • deepseek-v4-flash-vision-exp
  • deepseek-v4-pro
  • deepseek-v4-flash
  • deepseek-v4-flash-free

ZhipuGLM4

  • glm-5.3-flash
  • glm-5.3-flash-free
  • glm-5.3
  • glm-5.2

GrokGrok1

  • grok-4.6
  1. Leave request headers empty.
  2. Click Submit to save.

Note: the Custom provider form in OpenCode Desktop only supports the OpenAI protocol, so Claude requests sent through it can miss the prompt cache, fail, or cost more than they should. For Claude models, use the config file below instead.

Use a config file (opencode.json)

A config file can add a second provider that sends Claude requests in the native Anthropic Messages format, so Claude in OpenCode can use prompt caching and thinking the way it does in Claude Code. Long sessions cost less that way.

  1. Give OpenCode your API key. OpenCode 2 sends requests from a background service, so set the key there:
bash
opencode service set env APITOKENROUTER_API_KEY "your APITokenRouter API key"
  1. Add this to ~/.config/opencode/opencode.json (all projects) or to opencode.json in your project root:
json
{
  "$schema": "https://opencode.ai/config.json",
  "model": "teamorouter-claude/claude-sonnet-5-5",
  "providers": {
    "teamorouter": {
      "name": "APITokenRouter",
      "package": "@opencode/ai/providers/openai-compatible",
      "settings": {
        "baseURL": "https://apitokenrouter.com/v1",
        "apiKey": "{env:APITOKENROUTER_API_KEY}"
      },
      "models": {
        "gpt-6.1-sol": {},
        "gemini-4-argon": {},
        "deepseek-v4-pro": {},
        "kimi-k3.1-pro": {},
        "glm-5.3": {}
      }
    },
    "teamorouter-claude": {
      "name": "APITokenRouter (Claude)",
      "package": "@opencode/ai/providers/anthropic-compatible",
      "settings": {
        "baseURL": "https://apitokenrouter.com/v1",
        "apiKey": "{env:APITOKENROUTER_API_KEY}"
      },
      "models": {
        "claude-opus-5-5": {},
        "claude-sonnet-5-5": {},
        "claude-haiku-5-5": {}
      }
    }
  }
}
  1. Restart OpenCode, run /models and pick a model, for example teamorouter-claude/claude-sonnet-5-5.
  • teamorouter uses the OpenAI-compatible protocol for GPT, Gemini, DeepSeek, Kimi, GLM and other models. teamorouter-claude uses the Anthropic Messages protocol for Claude. Both use the same key and balance.

  • OpenCode 1 uses the older format: provider instead of providers, npm (@ai-sdk/openai-compatible, or @ai-sdk/anthropic for Claude) instead of package, and options instead of settings.

  • To add more models, put their IDs under models. GET /v1/models with your key lists every model ID.

2. Install OpenCode from scratch

Download and install

Install or upgrade from the OpenCode download page.

Run and configure

Run:

plaintext
opencode

Add APITokenRouter

Open OpenCode Desktop and follow steps 1 to 7 in the previous section.

Set the model

In Settings, choose Server -> Models and switch the default chat model to a APITokenRouter model. New conversations will use it by default.

Start using OpenCode

Return to the main OpenCode Desktop screen and create a new conversation.

Pay with USDT or USDC

You don't need a credit card to use OpenCode with APITokenRouter. Top up your balance with USDT, USDC or ETH straight from an exchange app (Binance, OKX and others) or any wallet: click Pay with crypto in the top-up dialog, pick a coin and network, and send. The minimum is $5 (USDT on BEP20), and no browser extension is needed. Step by step: Pay for Claude and GPT APIs with crypto (USDT).

Ready? Three steps to startLog in to the console · top up · create an API key
DiscordGet community help instantly
Install OpenCode and Connect It to APITokenRouter · Docs