LowRouter

OpenCode

OpenCode is a terminal coding assistant. It expects an OpenAI-compatible endpoint, which is what LowRouter exposes.

Configure

OpenCode reads its config from ~/.config/opencode/opencode.json. Point the OpenAI provider entry at LowRouter:

JSON
{
  "providers": {
    "openai": {
      "baseURL": "https://lowrouter.ai/api/v1",
      "apiKey": "lr-sk-..."
    }
  },
  "defaultModel": "lowrouter/auto"
}

Restart OpenCode after editing the file.

Picking a model

Inside OpenCode, run /model and pick from the list. If a model isn’t listed, type the LowRouter model ID directly — any model on the model browser is routable.

For coding tasks, the auto route (lowrouter/auto) generally picks something appropriate. If you want a specific model:

  • For long contexts: a model with ≥128K context window. The model browser tags context length per model.
  • For latency-sensitive iteration: an *-mini or *-haiku-* variant.
  • For careful reasoning: a top-tier reasoning model.
  • Dedicated key with a daily limit. OpenCode is interactive and it’s easy to lose track of how many tokens you spent in an afternoon. A daily limit on the key bounds the surprise.
  • Disable shell-execution tools by default. OpenCode supports letting the model run shell commands; turn that off until you’ve reviewed the prompts the agent sends. Enable it per-session for the workflow that needs it.
  • Stream on. Default in OpenCode; mentioned for completeness.

Troubleshooting

  • Hangs on the first request: confirm baseURL ends with /v1 (no trailing slash). OpenCode appends /chat/completions itself.
  • Model “not found”: the model isn’t in OpenCode’s autocomplete list, but it is routable. Run /model lowrouter/auto to confirm the gateway is reachable, then use the explicit model ID.