← Docs

Connect OpenCode to LaRouter

Use one LaRouter API key for your configured accounts. Each account retains its own quota.

Option 1: Use Configure

Sign in and select your local configuration file. Apply LaRouter fills your key and model and writes the file immediately; Reset defaults also writes immediately. If your browser cannot write local files, follow the manual instructions.

Configuration file location

macOS
~/.config/opencode/opencode.json
Linux
~/.config/opencode/opencode.json
Windows
%USERPROFILE%\.config\opencode\opencode.json

These are default locations. For a tool running in WSL, use its Linux path inside WSL. If you changed the configuration directory, select the tool’s actual file. Your browser can only read or write files you select.

Option 2: Configure manually

Back up your files and replace only the placeholders shown below. Codex already uses gpt-5.6-sol. Use model names without router prefixes such as cx/. Keep tool-required local provider bindings such as larouter/ where shown, and preserve unrelated settings.

Before you start

Retrieve your assigned key in the portal and make sure at least one account is connected. Shell examples use Bash or zsh on macOS/Linux. Replace YOUR_API_KEY, call /models, and replace YOUR_MODEL_ID with an ID supported by your accounts.

Environment
export LAROUTER_API_KEY="YOUR_API_KEY"
Available models
curl https://i-larouter.lapage.vn/v1/models \
  -H "Authorization: Bearer $LAROUTER_API_KEY"

Manual configuration

Install the tool first, back up its configuration, then merge the fields below. Replace YOUR_API_KEY and YOUR_MODEL_ID with your own values. Do not overwrite an existing file wholesale.

~/.config/opencode/opencode.json
{
  "model": "larouter/YOUR_MODEL_ID",
  "provider": {
    "larouter": {
      "npm": "@ai-sdk/openai-compatible",
      "options": {
        "baseURL": "https://i-larouter.lapage.vn/v1",
        "apiKey": "YOUR_API_KEY"
      },
      "models": {
        "YOUR_MODEL_ID": {
          "name": "YOUR_MODEL_ID"
        }
      }
    }
  }
}
Start the tool
opencode

OpenCode uses the larouter provider with @ai-sdk/openai-compatible. Select larouter/YOUR_MODEL_ID as the model. The configurator accepts plain JSON only; merge manually if you use opencode.jsonc so comments remain intact.

OpenCode | LaRouter setup instructions