查看中文版 →

Deutsche Version ansehen →

Открыть русскую версию →

Ver versión en español →

Log in
Blog · Setup guides

opencode-claude-auth: OAuth Limits and API Alternatives

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.

What opencode-claude-auth is and how it works

griffinmartin/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:

  • Local credential lookup: reads active OAuth tokens from the macOS Keychain, or from ~/.claude/.credentials.json (and $CLAUDE_CONFIG_DIR/.credentials.json) on Linux and Windows
  • In-memory token refresh: caches the credentials in memory and refreshes expiring tokens against Anthropic's OAuth endpoint, falling back to the Claude CLI if needed
  • Provider interception: hooks into OpenCode's built-in Anthropic provider and attaches bearer authentication so standard anthropic/<model> calls route through your subscription login

To 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.

~/.config/opencode/opencode.json
{  "plugins": [    "opencode-claude-auth@latest"  ]}

What happens when you run Claude Max via OAuth in OpenCode

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:

  • Account standing: automated agent loops running on consumer OAuth tokens sit outside Anthropic's permitted first-party scope and risk rate restrictions or account suspension
  • Maintenance churn: every upstream check update or OpenCode plugin API change breaks the bridge until community forks catch up
  • Supply-chain exposure: loading community auth plugins with @latest means an unreviewed package update runs with access to your local Keychain or ~/.claude/.credentials.json

opencode-claude-auth vs direct Anthropic API vs CodingPass

If 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.

Comparison of opencode-claude-auth OAuth, direct Anthropic API, and CodingPass API in OpenCode
OptionAuth and billingThird-party 400 / ToS riskModels in OpenCodeBudget control
opencode-claude-auth (OAuth)Claude Pro ($20/mo), Max ($100/mo), or Ultra ($200/mo) OAuth tokenHigh: credential blocks, extra-usage 400s, ToS conflictClaude onlyPlan limits blocked for third-party traffic; extra usage bills at API rates
Direct Anthropic APIStandard ANTHROPIC_API_KEY, pay-as-you-go per tokenNone: official third-party API pathClaude onlyUnbounded by default unless you configure console spend limits
CodingPass APIStandard CODINGPASS_API_KEY + baseURL, fixed monthly planNone: standard API key, no consumer OAuthClaude, GPT, Gemini, Grok, and open-weight modelsFixed monthly allowance with no surprise charges

Switching OpenCode to a standard API key

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.

Option 1: Direct Anthropic API

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):

Terminal
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.

Option 2: CodingPass API in OpenCode 2

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:

~/.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:

Terminal
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.

Which setup fits your workflow

Recommended Claude authentication setup by developer scenario
ScenarioRecommended setupWhy and trade-off
Already paying for Claude Pro or Max and happy with one CLIUse the official Claude Code CLI directlyStays inside plan limits with zero OAuth workarounds; gives up OpenCode's multi-model UI
Light or occasional Claude usage inside OpenCodeDirect 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 modelsCodingPass API in opencode.jsoncFixed monthly allowance, no surprise charges, and one config for Claude plus open-weight models
Experimenting with opencode-claude-auth in a personal sandboxPin an exact plugin version and budget for extra usageAvoids unreviewed @latest updates, but third-party calls still bypass plan limits and can break anytime

FAQ

Can I still use a Claude Max subscription inside OpenCode?

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.

Does using 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.

Do I need to reinstall OpenCode when switching from 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.

Boarding

Keep OpenCode. Drop the OAuth workarounds.

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.

  • Request ID on every response
  • Full refund if you've used 5% or less
  • No surprise charges
Choose GoOpenCode guide

$10/mo until you cancel.