SteadyRouterDocs

Docs › Setup guides

Use SteadyRouter with opencode

Add SteadyRouter to opencode's config as two providers with the same key: one using Anthropic's API format for Claude models, so prompt caching and extended thinking work as they do with Anthropic's API, and one using the OpenAI-compatible format for every other model.

Before you start

  1. Create a SteadyRouter account.
  2. In the console, open API Keys and copy your key. New accounts come with one called Default Key, on Lowest price (see below). To make another, click Create API Key. Keep Smart routing on: if a group fails, the request is retried in the next group within the same call. A new key starts on Auto, or on Lowest price if your balance is under US$1.
  3. Find the model names you want on Model Square. Model names have no vendor prefix, for example claude-sonnet-5-5 or gpt-5-mini.

1. Put the key in an environment variable

bash
export STEADYROUTER_API_KEY="sk-..."

Add the line to your shell profile (~/.zshrc, ~/.bashrc) to keep it.

2. Add the providers

Edit your global config, ~/.config/opencode/opencode.json (or opencode.json in a project to use it there only):

JSON
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "steadyrouter-claude": {
      "npm": "@ai-sdk/anthropic",
      "name": "SteadyRouter (Claude)",
      "options": {
        "baseURL": "https://api.steadyrouter.com/v1",
        "apiKey": "{env:STEADYROUTER_API_KEY}"
      },
      "models": {
        "claude-sonnet-5-5": { "name": "Claude Sonnet 5.5" },
        "claude-haiku-5-5": { "name": "Claude Haiku 5.5" }
      }
    },
    "steadyrouter": {
      "npm": "@ai-sdk/openai-compatible",
      "name": "SteadyRouter",
      "options": {
        "baseURL": "https://api.steadyrouter.com/v1",
        "apiKey": "{env:STEADYROUTER_API_KEY}"
      },
      "models": {
        "gpt-5-mini": { "name": "GPT-5 mini" }
      }
    }
  }
}

Add any other model from Model Square under models, using its name as the key. To tell opencode how much context a model has left, add "limit": { "context": <tokens>, "output": <tokens> } to that model, using the numbers from the model developer's documentation.

3. Pick a model

Start opencode, run /models, and choose one of the SteadyRouter models.

Trying it on a small balance

New accounts currently start with US$0.05 of credit. Before each request, the gateway reserves balance based on the input plus the maximum output the client asks for, and coding clients ask for a lot: often around 20,000 tokens of context and 32,000 or more output tokens. With a small balance:

  1. Use Lowest price under Smart routing on your API key. Default Key is already on it; for another key, choose it when you create the key or later by editing it.
  2. Start with a smaller model. On Lowest price, a request to claude-haiku-5-5 or gpt-5-mini costs a small fraction of the same request to larger models such as claude-sonnet-5-5, gpt-5.5 or claude-opus-5-5.
  3. Set a low output limit on that model, for example "limit": { "context": 200000, "output": 8192 }. This lowers the amount reserved per request.

Once you've confirmed everything works, add funds to use larger models, and switch the key back to Auto if you prefer.

Lowest price often puts Pool groups first: usually cheaper, sometimes less stable. In every smart routing mode, Pool and Mixed groups can be used, so for stability-critical work, turn smart routing off and list only cloud or API groups on the key. See Models and groups.

If something goes wrong

What you seeWhat to do
The models don't show up in /modelsCheck that opencode.json is valid JSON and that STEADYROUTER_API_KEY is set in the shell you started opencode from, then restart opencode.
404Check baseURL: it is https://api.steadyrouter.com/v1 for both providers.
401 Invalid tokenThe key is wrong, disabled, expired or out of its spending cap. Check it under API Keys.
403 insufficient_user_quotaYour balance can't cover the request. Top up, or follow the small-balance steps above.
503 model_not_foundThe model name is wrong, or the groups your key uses don't offer it. Check the name on Model Square.
408, 504 or 524An upstream timeout. These are not moved to another group automatically, so retry.

Every error message ends with a request id. Include it when you email support@steadyrouter.com.

More: API docs · Model Square