---
title: "opencode-claude-auth: How It Works, OAuth Limits, and API Alternatives"
description: "How the opencode-claude-auth plugin reads Claude Pro and Max OAuth tokens, why Anthropic restricts third-party subscription usage, and how to switch OpenCode to a standard API key."
url: https://codingpass.ai/blog/opencode-claude-auth-oauth-limits-alternatives
language: en
updated: 2026-12-01
---
# 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.

[CodingPass team](https://codingpass.ai/about) Published Dec 1, 2026 Updated Dec 1, 2026 7 min read

**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](https://github.com/anomalyco/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`](https://github.com/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](https://codingpass.ai/blog/opencode-claude-third-party-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.

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

## 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](https://console.anthropic.com/) 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](https://codingpass.ai/blog/how-to-use-claude-in-opencode) or the [OpenCode setup guide](https://codingpass.ai/tools/opencode). Check the [Models page](https://codingpass.ai/models) for current model IDs and [Pricing](https://codingpass.ai/pricing) for plan allowances.

## Which setup fits your workflow

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

## 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](https://codingpass.ai/tools/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.

Written by CodingPass team

We run CodingPass and test each guide against the latest stable release of the tool before we publish it. Spotted something out of date? Write to [support@codingpass.ai](mailto:support@codingpass.ai).

## Related reading.

Guide

### [OpenCode 2 works great, until Claude returns a 400](https://codingpass.ai/blog/opencode-claude-third-party-400)

Packet-level reproduction of the extra-usage 400 error triggered by the environment block in the system prompt.

Guide

### [How to Use Claude in OpenCode](https://codingpass.ai/blog/how-to-use-claude-in-opencode)

OpenCode 2 overview and a complete opencode.jsonc setup for Claude, GPT, and open-weight models.

Guide

### [OpenCode setup guide](https://codingpass.ai/tools/opencode)

Three-step setup, default models for each plan, and allowances for open-weight models.
