Use Claude in OpenCode with a custom base URL
Point OpenCode's built-in Anthropic provider at AI in IDE with one config block and run Claude Opus 5.5, Sonnet 5.5, or Haiku 4.5 without an Anthropic account.
Tested on 2026-11-06 with OpenCode 1.2.27: opencode run returned a reply from claude-sonnet-5-5 and claude-haiku-4-5-20251001 through the settings below.
Setup at a glance
- Create the API key. Open API Keys, create a key, and choose the AWSQ or CCMAX channel. A Codex or Gemini key is rejected on the Claude endpoint.
- Export the key. Add
export AIINIDE_API_KEY="YOUR_DASHBOARD_API_KEY"to~/.zshrcor~/.bashrc, then open a new terminal. - Write the provider override. Put this in
~/.config/opencode/opencode.jsonfor every project, or inopencode.jsonat a project root for one project:
1 {2 "$schema": "https://opencode.ai/config.json",3 "provider": {4 "anthropic": {5 "options": {6 "baseURL": "https://api.aiinide.com/v1",7 "apiKey": "{env:AIINIDE_API_KEY}"8 }9 }10 },11 "model": "anthropic/claude-sonnet-5-5"12 }
- Verify. Run
opencode run "Reply with exactly: OK". The header showsclaude-sonnet-5-5and the reply isOK. The request appears in Usage.
The base URL must end in /v1
OpenCode's Anthropic provider appends /messages, so it needs https://api.aiinide.com/v1. With the bare host it calls /messages and fails with Error: Not Found. Claude Code is the opposite: it appends /v1/messages and needs the bare host. Do not copy one tool's value into the other.
Models
| Model ID in OpenCode | Channel | Use it for |
|---|---|---|
anthropic/claude-opus-5-5 | AWSQ, CCMAX | hard refactors, long agent runs |
anthropic/claude-sonnet-5-5 | AWSQ, CCMAX | everyday coding |
anthropic/claude-haiku-4-5-20251001 | AWSQ, CCMAX | quick edits, cheap checks |
Change model in the config to switch the default. Use exact IDs from GET /v1/models. Rates and channel multipliers are on Models and pricing.
FAQ
Which base URL does OpenCode need for AI in IDE?
https://api.aiinide.com/v1. OpenCode appends /messages to it; the bare host returns Not Found.
Do I need to run /connect?
No. The apiKey option reads the key from AIINIDE_API_KEY, so nothing is stored in auth.json. Run opencode auth list to see whether an older Anthropic key is stored there.
Does this change OpenCode for other providers?
No. Only the anthropic provider is redirected. OpenAI, Google, and other providers keep their own endpoints and keys.
Can I keep the key out of the project repository?
Yes. Keep the key in an environment variable and reference it with {env:AIINIDE_API_KEY}. A project opencode.json that only contains that reference is safe to commit.