How to Use Claude Max with OpenCode (Fix the “Out of Extra Usage” Error)
If you’re using OpenCode with a Claude Max subscription, you’ve probably hit this error:
✗ opencode session error: You're out of extra usage. Add more at claude.ai/settings/usage and keep going. (400)
You’re not out of usage. Anthropic is detecting that you’re making API calls from OpenCode — not Claude Code — and blocking the request. The error message is misleading.
Here’s how to fix it.
What’s Happening
Anthropic inspects the system[] array in API requests made with Claude Max OAuth tokens. When the system prompt doesn’t match Claude Code’s fingerprint, they return a 400 “out of extra usage” error. This was diagnosed in opencode-claude-auth issue #145 and kimaki issue #99:
- Small system prompt → ✅ works
- Full 30K OpenCode system prompt → ❌ blocked
- Same 30K prompt filled with “AAAA…” → ✅ works
- Full prompt moved to user message → ✅ works
It’s content-based detection on the system prompt — not headers, request size, or betas.
The Fix: opencode-claude-auth
The opencode-claude-auth plugin works around this by:
- Authenticating with your Claude Max OAuth token
- Injecting the same billing header Claude Code sends
- Keeping a minimal identity in
system[]and relocating the rest into the first user message
Your prompts work identically — they just live in a different part of the request payload.
Local Setup (Quick Fix)
Add the plugin to your opencode.json:
{
"plugin": [
"opencode-claude-auth@latest"
]
}
Then authenticate:
opencode providers
Select Anthropic and log in with your Claude Max account. Done.
VPS Setup (with WordPress)
Running on a VPS is more involved because there’s no browser or keychain — you need to manage OAuth tokens and keep them fresh. wp-coding-agents handles the full setup: WordPress + agent memory + OpenCode + Discord bridge, all wired together.
Step 1: Run the setup script
git clone https://github.com/Extra-Chill/wp-coding-agents.git
cd wp-coding-agents
SITE_DOMAIN=yourdomain.com ./setup.sh
This installs:
- WordPress — the site platform
- Data Machine — persistent agent memory (SOUL.md, USER.md, MEMORY.md), scheduling, and AI tools via WP-CLI and the WordPress Abilities API
- OpenCode — the coding agent runtime
- opencode-claude-auth@latest — already in
opencode.jsonplugin list - Kimaki — Discord bridge
- A wrapper script at
/usr/local/bin/opencodethat syncs credentials between Kimaki and opencode-claude-auth before each session
Step 2: Authenticate with Claude Max
cd /var/www/yourdomain.com && kimaki
Kimaki walks you through Discord bot setup and AI provider authentication. Log in with your Claude Max account. Kimaki stores the OAuth tokens and handles refresh automatically.
Step 3: Done
Every OpenCode session using Anthropic models will automatically get the billing header and system prompt relocation. No manual credential management needed.
How the Credential Flow Works
On a VPS, three pieces need to stay in sync:
Kimaki manages OAuth refresh
└─ stores tokens in anthropic-oauth-accounts.json
│
▼ (wrapper syncs before each opencode invocation)
~/.claude/.credentials.json
│
▼ (opencode-claude-auth reads from here)
Plugin injects billing headers + relocates system prompt
│
▼
Anthropic API ✅
- Kimaki handles the OAuth lifecycle — refresh, rotation, multi-account
- The wrapper syncs Kimaki’s credential store into
~/.claude/.credentials.json(the format opencode-claude-auth reads) - opencode-claude-auth handles the API-level transforms — billing headers and system prompt relocation
The Full Stack
- WordPress — the operating layer. Data Machine turns it into agent infrastructure.
- Data Machine — persistent agent memory, scheduling, AI tools, all via WP-CLI and the WordPress Abilities API
- OpenCode — the coding agent runtime
- opencode-claude-auth — Claude Max auth + billing header injection + system prompt relocation
- Kimaki — Discord bridge (chat with your agent, manages OAuth tokens)
- wp-coding-agents — setup script that wires it all together
The entire stack is open source.
Why OpenCode
Claude is the best model out there right now, and $200/month for Claude Max is worth it — even though it’s still rate limited, not unlimited. But Anthropic wants to keep it as a Claude Code product, not a generic API key you can pipe into any tool.
I prefer OpenCode because it lets you switch providers. You can use Claude when you want the best results, and fall back to other models when you hit rate limits. Plus, the entire stack is open source — OpenCode, Data Machine, Kimaki, wp-coding-agents.
The workaround is clean — the billing header is accurate (you are on Max), the identity prefix is a technical requirement, and your actual prompts live in the user message where they work identically. You’re using the models you pay for with the tools you prefer.
Links
- wp-coding-agents — the setup script
- opencode-claude-auth — the auth plugin
- GitHub issue #145 — the thread that diagnosed the problem
- Kimaki issue #99 — the same issue from the Kimaki side
- Data Machine — persistent agent memory on WordPress
- Kimaki — Discord bridge for AI agents