/Docs
Back to dashboard

OpenCode

Set up OpenCode with Claude API — open-source terminal AI assistant. Configure API key and model selection.

LLMsRelay is an independently operated API gateway. It is not affiliated with or endorsed by Anthropic, PBC. Product and model names are used only to describe compatibility.

Config Path

Windows:

C:\Users\User\.config\opencode\opencode.jsonc

Linux / macOS:

~/.config/opencode/opencode.jsonc

Example Config

opencode.jsoncjson
{
  "$schema": "https://opencode.ai/config.json",
  "provider": {
    "anthropic": {
      "options": {
        "baseURL": "https://api.llmsrelay.com",
        "apiKey": "sk-cs4-YOUR_KEY"
      }
    }
  }
}

Notes

  • Use your API key from the dashboard
  • OpenCode should point to the bare Anthropic-compatible host: https://api.llmsrelay.com (no /v1)
  • Recommended model IDs are the same stable Claude IDs used everywhere else

Windows setup

1. Install OpenCode

OpenCode ships as a standalone binary or via npm. Easiest path on Windows:

npm install -g opencode-ai
opencode --version

Alternative: download opencode-windows-x64.exe from GitHub Releases and put it on your PATH.

2. Create the config folder

OpenCode reads %USERPROFILE%\.config\opencode\opencode.jsonc:

mkdir $env:USERPROFILE\.config\opencode -ErrorAction SilentlyContinue
notepad $env:USERPROFILE\.config\opencode\opencode.jsonc

Paste the example config from the section above.

3. Optional: env vars instead of JSON

If you prefer environment variables, set them once with setx:

setx ANTHROPIC_BASE_URL "https://api.llmsrelay.com"
setx ANTHROPIC_API_KEY "sk-cs4-YOUR_KEY"
setx takes effect only in NEW terminals — open a fresh PowerShell.

4. WSL note

If you run OpenCode inside WSL, the config path becomes ~/.config/opencode/opencode.jsonc and Windows env vars do not propagate — re-export them in ~/.bashrc.

5. Troubleshooting

  • "opencode" not recognized — open a new PowerShell, or add %APPDATA%\npm to PATH.
  • JSONC parse error — Notepad may save the file as UTF-8 with BOM. Use VS Code or notepad++ and save as UTF-8 (no BOM).
  • 404 on requests — verify baseURL is exactly https://api.llmsrelay.com and does not include /v1.
  • SmartScreen warning on first launch — click "More info" → "Run anyway" once, Windows will remember the choice.

Ready to start?

Create a key and configure a compatible API route in under 2 minutes.

View Plans