Skip to content

John-Rood/claude-proxy

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Claude Code Proxy

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.

What It Does

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

Setup

git clone https://github.com/John-Rood/claude-proxy.git
cd claude-proxy
node index.js

That's it. No dependencies to install.

Configuration

config.json:

{
  "port": 8082
}

Usage

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"}]
  }'

Endpoints

Endpoint Method Description
/v1/messages POST Proxied to Anthropic with Claude Code envelope
/health GET Health check
/status GET Proxy status and request count

Requirements

  • Node.js 18+
  • A valid Anthropic API key (from an account with Claude Code / Max subscription)

Run as a Service (macOS)

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

The proxy will auto-restart on crash and start on boot.

OpenClaw Skill (Troubleshooting)

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

Install the skill

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.

License

MIT

About

Lightweight proxy that routes Anthropic API billing through Claude Code subscriptions. Zero dependencies, ~150 lines.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors