A lightweight Node.js proxy (~150 lines, zero dependencies) that wraps Anthropic API requests with the Claude Code envelope, routing billing through your Claude Code subscription instead of direct API credits.
Your App → localhost:8082 → Proxy → api.anthropic.com
↓
1. Pass through your API key unchanged
2. Add anthropic-beta: claude-code-20250219 header
3. Prepend Claude Code system prompt
4. Stream response back untouched
git clone https://github.com/John-Rood/claude-proxy.git
cd claude-proxy
node index.jsThat's it. No dependencies to install.
config.json:
{
"port": 8082
}Point your Anthropic client at http://127.0.0.1:8082 instead of https://api.anthropic.com. The proxy passes through your API key and adds the Claude Code billing envelope.
curl http://127.0.0.1:8082/v1/messages \
-H "Content-Type: application/json" \
-H "x-api-key: YOUR_ANTHROPIC_KEY" \
-H "anthropic-version: 2023-06-01" \
-d '{
"model": "claude-sonnet-4-20250514",
"max_tokens": 100,
"messages": [{"role": "user", "content": "Hello"}]
}'| Endpoint | Method | Description |
|---|---|---|
/v1/messages |
POST | Proxied to Anthropic with Claude Code envelope |
/health |
GET | Health check |
/status |
GET | Proxy status and request count |
- Node.js 18+
- A valid Anthropic API key (from an account with Claude Code / Max subscription)
To keep the proxy running persistently, create a launchd plist at ~/Library/LaunchAgents/com.claude-proxy.plist:
<?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-proxy</string>
<key>ProgramArguments</key>
<array>
<string>/path/to/node</string>
<string>/path/to/claude-proxy/index.js</string>
</array>
<key>WorkingDirectory</key>
<string>/path/to/claude-proxy</string>
<key>RunAtLoad</key>
<true/>
<key>KeepAlive</key>
<dict>
<key>SuccessfulExit</key>
<false/>
</dict>
<key>StandardOutPath</key>
<string>/tmp/claude-proxy-stdout.log</string>
<key>StandardErrorPath</key>
<string>/tmp/claude-proxy-stderr.log</string>
<key>ThrottleInterval</key>
<integer>10</integer>
<key>EnvironmentVariables</key>
<dict>
<key>PATH</key>
<string>/opt/homebrew/bin:/usr/local/bin:/usr/bin:/bin</string>
</dict>
</dict>
</plist>Replace /path/to/node with your node binary path (which node) and /path/to/claude-proxy with where you cloned this repo.
launchctl load ~/Library/LaunchAgents/com.claude-proxy.plistThe proxy will auto-restart on crash and start on boot.
This repo includes an OpenClaw skill for automated troubleshooting. If you're using OpenClaw and the proxy stops working, the skill walks your agent through diagnosing and fixing common issues (baseUrl overwrites, auth token cycling, Keychain sync, etc).
Copy the skill folder into your OpenClaw workspace:
cp -r skills/anthropic-sub-proxy ~/.openclaw/workspace/skills/Or if your workspace is in a different location:
cp -r skills/anthropic-sub-proxy /path/to/your/openclaw/workspace/skills/That's it — OpenClaw will automatically detect the skill and use it when proxy-related issues come up.
MIT