Use your Claude Max subscription with OpenCode.
Anthropic doesn't allow Claude Max subscribers to use their subscription with third-party tools like OpenCode. If you want to use Claude in OpenCode, you have to pay for API access separately - even though you're already paying for "unlimited" Claude.
Your options are:
- Use Claude's official apps only (limited to their UI)
- Pay again for API access on top of your Max subscription
- Use this proxy
This proxy bridges the gap using Anthropic's own tools:
OpenCode → Proxy (localhost:3456) → Claude Agent SDK → Your Claude Max Subscription
The Claude Agent SDK is Anthropic's official npm package that lets developers build with Claude using their Max subscription. This proxy simply translates OpenCode's API requests into SDK calls.
Your Max subscription. Anthropic's official SDK. Zero additional cost.
Yes. Here's why:
| Concern | Reality |
|---|---|
| "Bypassing restrictions" | No. We use Anthropic's public SDK exactly as documented |
| "Violating TOS" | No. The SDK is designed for programmatic Claude access |
| "Unauthorized access" | No. You authenticate with claude login using your own account |
| "Reverse engineering" | No. We call query() from their npm package, that's it |
The Claude Agent SDK exists specifically to let Max subscribers use Claude programmatically. We're just translating the request format so OpenCode can use it.
~200 lines of TypeScript. No hacks. No magic. Just format translation.
| Feature | Description |
|---|---|
| Zero API costs | Uses your Claude Max subscription, not per-token billing |
| Full compatibility | Works with any Anthropic model in OpenCode |
| Streaming support | Real-time SSE streaming just like the real API |
| Auto-start | Optional launchd service for macOS |
| Simple setup | Two commands to get running |
-
Claude Max subscription - Subscribe here
-
Claude CLI installed and authenticated:
npm install -g @anthropic-ai/claude-code claude login
-
Bun runtime:
curl -fsSL https://bun.sh/install | bash
git clone https://github.com/rynfar/opencode-claude-max-proxy
cd opencode-claude-max-proxy
bun installbun run proxyANTHROPIC_API_KEY=dummy ANTHROPIC_BASE_URL=http://127.0.0.1:3456 opencodeSelect any anthropic/claude-* model (opus, sonnet, haiku).
bun run proxy & ANTHROPIC_API_KEY=dummy ANTHROPIC_BASE_URL=http://127.0.0.1:3456 opencodeSet up the proxy to run automatically on login:
cat > ~/Library/LaunchAgents/com.claude-max-proxy.plist << EOF
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>Label</key>
<string>com.claude-max-proxy</string>
<key>ProgramArguments</key>
<array>
<string>$(which bun)</string>
<string>run</string>
<string>proxy</string>
</array>
<key>WorkingDirectory</key>
<string>$(pwd)</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<true/>
</dict>
</plist>
EOF
launchctl load ~/Library/LaunchAgents/com.claude-max-proxy.plistThen add an alias to ~/.zshrc:
echo "alias oc='ANTHROPIC_API_KEY=dummy ANTHROPIC_BASE_URL=http://127.0.0.1:3456 opencode'" >> ~/.zshrc
source ~/.zshrcNow just run oc to start OpenCode with Claude Max.
| OpenCode Model | Claude SDK |
|---|---|
anthropic/claude-opus-* |
opus |
anthropic/claude-sonnet-* |
sonnet |
anthropic/claude-haiku-* |
haiku |
| Environment Variable | Default | Description |
|---|---|---|
CLAUDE_PROXY_PORT |
3456 | Proxy server port |
CLAUDE_PROXY_HOST |
127.0.0.1 | Proxy server host |
- OpenCode sends a request to
http://127.0.0.1:3456/messages(thinking it's the Anthropic API) - Proxy receives the request and extracts the messages
- Proxy calls
query()from the Claude Agent SDK with your prompt - Claude Agent SDK authenticates using your Claude CLI login (tied to your Max subscription)
- Claude processes the request using your subscription
- Proxy streams the response back in Anthropic SSE format
- OpenCode receives the response as if it came from the real API
The proxy is ~200 lines of TypeScript. No magic, no hacks.
OpenCode requires an API key to be set, but we never actually use it. The Claude Agent SDK handles authentication through your Claude CLI login. Any non-empty string works.
Yes! Any tool that uses the Anthropic API format can use this proxy. Just point ANTHROPIC_BASE_URL to http://127.0.0.1:3456.
Your Claude Max subscription has its own usage limits. This proxy doesn't add any additional limits.
No. The proxy runs locally on your machine. Your requests go directly to Claude through the official SDK.
Run claude login to authenticate with the Claude CLI.
Make sure the proxy is running: bun run proxy
Use the launchd service (see Auto-start section) which automatically restarts the proxy.
MIT
Built with the Claude Agent SDK by Anthropic.