OpenCode plugin for Anthropic Claude Pro/Max OAuth login — no Claude Code needed.
OpenCode V2 note: OpenCode 2.2.3 added a built-in Claude Agent provider. That approach runs Claude Code through Anthropic's Agent SDK: install Claude Code, run
claude auth login, then select Claude Agent in OpenCode's/connectmenu. It requires Claude Code to be installed; this plugin instead authenticates directly via OAuth without installing Claude Code. Built-in support does not imply Anthropic approval, and Anthropic's terms and Agent SDK authentication policy still apply. This plugin is a separate community workaround, not an official Anthropic integration or a guarantee of V2 compatibility.
Lets you authenticate with your Claude Pro/Max subscription directly in OpenCode via browser OAuth. No need to install Claude Code or manage credentials files.
npm install -g opencode-anthropic-oauthThen add to your opencode.json:
{
"plugin": ["opencode-anthropic-oauth"]
}- Run
/connectin OpenCode (oroc auth loginfrom CLI) - Select Anthropic > Claude Pro/Max
- Open the link in your browser and authorize
- Paste the code back into OpenCode
- Done — all Anthropic models are now available
- Implements the OAuth PKCE flow directly against Anthropic's auth endpoints
- Opens your browser for authentication — you log in with your Claude account
- Exchanges the authorization code for access + refresh tokens
- Auto-refreshes tokens when they expire — no manual re-auth needed
- Sets the required API headers on Anthropic requests
- Preserves prompt caching for efficient token usage
- Fixed high token consumption — removed
cache_controlstripping that was disabling prompt caching - Added
x-anthropic-billing-headerfor proper token tracking - Aligned beta flags with official Claude CLI plugin
- Added
?beta=trueURL parameter for OAuth compatibility - Injected system identity prefix for claude-code beta
- Stripped
cache_control(now removed in 0.4.1)
- Added auto token refresh via loader hook
- Background proactive refresh timer (5min intervals)
All OAuth parameters can be overridden via environment variables. If Anthropic changes something before we publish an update, set an env var and keep working:
| Variable | Description |
|---|---|
ANTHROPIC_CLIENT_ID |
OAuth client ID |
ANTHROPIC_CLI_VERSION |
Claude CLI version for User-Agent |
ANTHROPIC_USER_AGENT |
Full User-Agent string (overrides version) |
ANTHROPIC_AUTHORIZE_URL |
OAuth authorization endpoint |
ANTHROPIC_TOKEN_URL |
OAuth token endpoint |
ANTHROPIC_REDIRECT_URI |
OAuth redirect URI |
ANTHROPIC_SCOPES |
OAuth scopes |
ANTHROPIC_BETA_FLAGS |
Anthropic beta feature flags |
Example:
export ANTHROPIC_CLI_VERSION=2.2.0This plugin uses Anthropic's public OAuth client ID to authenticate. Anthropic's Terms of Service (February 2026) state that Claude Pro/Max subscription tokens should only be used with official Anthropic clients. This plugin exists as a community workaround and may stop working if Anthropic changes their OAuth infrastructure. Use at your own discretion.
MIT