OpenCode 2 works great, until Claude returns a 400
Packet-level reproduction of the extra-usage 400 error triggered by the environment block in the system prompt.
opencode-claude-auth lets OpenCode reuse local Claude Code credentials, but Anthropic now restricts consumer OAuth tokens in third-party clients. Here is how the plugin works, what breaks, and how to move to a clean API setup.
Verdict: opencode-claude-auth bridges your local Claude Code OAuth session into OpenCode, but Anthropic now restricts consumer Pro, Max, and Ultra subscription tokens to first-party tools. Third-party calls either fail with credential errors or draw from prepaid extra usage instead of plan limits. For reliable daily work in OpenCode, switch to a standard API key via the direct Anthropic API or CodingPass.
Developers searching for opencode-claude-auth usually want one thing: to run their existing Claude Pro ($20/month) or Claude Max ($100/month) subscription inside OpenCode without paying again for pay-as-you-go API tokens. The plugin made that possible for a while, until Anthropic tightened both its terms and its server-side checks.
opencode-claude-auth is and how it worksgriffinmartin/opencode-claude-auth is an open-source community plugin for OpenCode. Rather than running a separate browser login flow inside OpenCode, it reuses the OAuth session already created by Anthropic's official Claude Code CLI (claude auth login).
Under the hood, the plugin runs through three steps:
~/.claude/.credentials.json (and $CLAUDE_CONFIG_DIR/.credentials.json) on Linux and Windowsanthropic/<model> calls route through your subscription loginTo install it, developers add the package to ~/.config/opencode/opencode.json (using "plugin" on OpenCode 1.x or "plugins" on OpenCode 2.x; plugin v3.0.0+ targets OpenCode 2.0+). OpenCode installs npm plugins automatically with Bun on startup, and running /connect lets you pick Anthropic and import the local Claude Code subscription.
{ "plugins": [ "opencode-claude-auth@latest" ]}Using consumer subscription credentials inside a third-party harness now collides with Anthropic's 2026 policy and server-side enforcement. That enforcement rolled out in two main waves.
First, Anthropic restricted consumer OAuth tokens to first-party clients and updated its terms to prohibit routing Free, Pro, or Max OAuth tokens through third-party agent frameworks. OpenCode removed native Claude OAuth support, and third-party requests using subscription credentials started hitting hard rejections:
This credential is only authorized for use with Claude Code and cannot be used for other API requests.Second, starting April 4, 2026, Anthropic separated third-party tool usage from consumer plan limits. Subscription allowances on Pro ($20/month), Max ($100/month, formerly Max 5x), and Ultra ($200/month, formerly Max 20x) apply to claude.ai, the official Claude Code CLI, and Cowork. Traffic classified as a third-party app draws from prepaid extra usage at API rates instead of plan limits. When extra usage is disabled or empty, OpenCode receives a 400 error:
400 Third-party apps now draw from extra usage, not plan limits.Because upstream inspects the request payload rather than just headers, a short request like session title generation can return 200 while the main tool-calling request fails with 400. We documented that packet-level reproduction in OpenCode 2 works great, until Claude returns a 400.
Beyond broken requests, relying on opencode-claude-auth carries three practical risks:
@latest means an unreviewed package update runs with access to your local Keychain or ~/.claude/.credentials.jsonopencode-claude-auth vs direct Anthropic API vs CodingPassIf you want to keep OpenCode as your editor and terminal agent, you have three ways to supply Claude models. The table below compares how each option handles authentication, reliability, model choice, and monthly spend.
| Option | Auth and billing | Third-party 400 / ToS risk | Models in OpenCode | Budget control |
|---|---|---|---|---|
opencode-claude-auth (OAuth) | Claude Pro ($20/mo), Max ($100/mo), or Ultra ($200/mo) OAuth token | High: credential blocks, extra-usage 400s, ToS conflict | Claude only | Plan limits blocked for third-party traffic; extra usage bills at API rates |
| Direct Anthropic API | Standard ANTHROPIC_API_KEY, pay-as-you-go per token | None: official third-party API path | Claude only | Unbounded by default unless you configure console spend limits |
| CodingPass API | Standard CODINGPASS_API_KEY + baseURL, fixed monthly plan | None: standard API key, no consumer OAuth | Claude, GPT, Gemini, Grok, and open-weight models | Fixed monthly allowance with no surprise charges |
Moving off opencode-claude-auth takes about two minutes. Start by removing "opencode-claude-auth@latest" (and any fork such as opencode-anthropic-auth) from the "plugins" or "plugin" array in ~/.config/opencode/opencode.json so OpenCode stops intercepting Anthropic requests.
Create an API key in the Anthropic Console and store it in OpenCode 2's background service environment (or export it in your shell for OpenCode 1.x):
opencode service set env ANTHROPIC_API_KEY sk-ant-…Restart OpenCode, run /models, and pick any standard anthropic/<model> entry. Requests go straight through Anthropic's developer API with no client-type checks, billed per token.
If you want a fixed monthly bill and access to Claude alongside open-weight models like DeepSeek and Kimi inside the same /models picker, configure CodingPass in ~/.config/opencode/opencode.jsonc:
{ "$schema": "https://opencode.ai/config.json", "model": "codingpass/claude-sonnet-5-5", "providers": { "codingpass": { "name": "CodingPass", "env": ["CODINGPASS_API_KEY"], "package": "@opencode/ai/providers/anthropic", "settings": { "baseURL": "https://codingpass.ai/v1" }, "models": { "claude-sonnet-5-5": { "name": "Claude Sonnet 5.5" }, "claude-opus-5-5": { "name": "Claude Opus 5.5" }, "deepseek-v4.1-flash": { "name": "DeepSeek V4.1 Flash" }, "kimi-k2.7-code": { "name": "Kimi K2.7 Code" } } } }}Then save your key to the OpenCode background service so both the CLI and desktop app can read it:
opencode service set env CODINGPASS_API_KEY cp-live-…Restart OpenCode, run /models, and choose Claude Sonnet 5.5 under CodingPass. For the full walkthrough including GPT models and desktop setup, see How to Use Claude in OpenCode or the OpenCode setup guide. Check the Models page for current model IDs and Pricing for plan allowances.
| Scenario | Recommended setup | Why and trade-off |
|---|---|---|
| Already paying for Claude Pro or Max and happy with one CLI | Use the official Claude Code CLI directly | Stays inside plan limits with zero OAuth workarounds; gives up OpenCode's multi-model UI |
| Light or occasional Claude usage inside OpenCode | Direct Anthropic API (ANTHROPIC_API_KEY) | Clean official API path with zero fixed monthly fee; heavy agent loops can run up per-token bills quickly |
| Daily OpenCode sessions across Claude and open-weight models | CodingPass API in opencode.jsonc | Fixed monthly allowance, no surprise charges, and one config for Claude plus open-weight models |
Experimenting with opencode-claude-auth in a personal sandbox | Pin an exact plugin version and budget for extra usage | Avoids unreviewed @latest updates, but third-party calls still bypass plan limits and can break anytime |
Only through extra usage credits, not your standard plan limits. Since April 4, 2026, Anthropic routes third-party tool calls away from Pro, Max, and Ultra plan limits into prepaid extra usage billed at API rates. If you want your Max subscription to count against plan limits, run the official Claude Code CLI directly.
opencode-claude-auth risk my Anthropic account?It sits in a policy gray area. Anthropic's updated consumer terms restrict subscription OAuth tokens to first-party apps like claude.ai and Claude Code. Light testing usually hits 400 or credential errors first, while heavy automated loops through third-party harnesses carry a higher risk of account flags or suspension.
opencode-claude-auth to an API key?No. Remove the plugin entry from ~/.config/opencode/opencode.json, set ANTHROPIC_API_KEY or CODINGPASS_API_KEY via opencode service set env, and restart OpenCode. Your existing sessions and project settings stay intact.
Point opencode.jsonc at CodingPass with a standard API key to run Claude and open-weight models on a fixed monthly allowance. No surprise charges, cancel anytime.