Actively maintained fork of atalovesyou/claude-max-api-proxy with OpenClaw integration, improved streaming, and expanded model support.
Use your Claude Max subscription ($200/month) with any OpenAI-compatible client — no separate API costs!
This proxy wraps the Claude Code CLI as a subprocess and exposes an OpenAI-compatible HTTP API, allowing tools like OpenClaw, Continue.dev, or any OpenAI-compatible client to use your Claude Max subscription instead of paying per-API-call.
| Approach | Cost | Limitation |
|---|---|---|
| Claude API | ~$15/M input, ~$75/M output tokens | Pay per use |
| Claude Max | $200/month flat | OAuth blocked for third-party API use |
| This Proxy | $0 extra (uses Max subscription) | Routes through CLI |
Anthropic blocks OAuth tokens from being used directly with third-party API clients. However, the Claude Code CLI can use OAuth tokens. This proxy bridges that gap by wrapping the CLI and exposing a standard API.
Your App (OpenClaw, Continue.dev, etc.)
↓
HTTP Request (OpenAI format)
↓
Claude Max API Proxy (this project)
↓
Claude Code CLI (subprocess)
↓
OAuth Token (from Max subscription)
↓
Anthropic API
↓
Response → OpenAI format → Your App
- OpenAI-compatible API — Works with any client that supports OpenAI's API format
- Streaming support — Real-time token streaming via Server-Sent Events
- Multiple models — Claude Opus, Sonnet, and Haiku with flexible model aliases
- OpenClaw integration — Automatic tool name mapping and system prompt adaptation
- Content block handling — Proper text block separators for multi-block responses
- Session management — Maintains conversation context via session IDs
- Auto-start service — Optional LaunchAgent for macOS
- Zero configuration — Uses existing Claude CLI authentication
- Secure by design — Uses
spawn()to prevent shell injection
- OpenClaw tool mapping — Maps OpenClaw tool names (
exec,read,web_search, etc.) to Claude Code equivalents (Bash,Read,WebSearch) - System prompt stripping — Removes OpenClaw-specific tooling sections that confuse the CLI
- Content block support — Handles
input_textcontent blocks and multi-block text separators - Tool call types — Full OpenAI tool call type definitions for streaming and non-streaming
- Improved streaming — Better SSE handling with connection confirmation and client disconnect detection
- Claude Max subscription ($200/month) — Subscribe here
- Claude Code CLI installed and authenticated:
npm install -g @anthropic-ai/claude-code claude auth login
# Clone the repository
git clone https://github.com/wende/claude-max-api-proxy.git
cd claude-max-api-proxy
# Install dependencies
npm install
# Build
npm run buildnpm start
# or
node dist/server/standalone.jsThe server runs at http://localhost:3456 by default. Pass a custom port as an argument:
node dist/server/standalone.js 8080# Health check
curl http://localhost:3456/health
# List models
curl http://localhost:3456/v1/models
# Chat completion (non-streaming)
curl -X POST http://localhost:3456/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4",
"messages": [{"role": "user", "content": "Hello!"}]
}'
# Chat completion (streaming)
curl -N -X POST http://localhost:3456/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check |
/v1/models |
GET | List available models |
/v1/chat/completions |
POST | Chat completions (streaming & non-streaming) |
| Model ID | Alias | CLI Model |
|---|---|---|
claude-opus-4 |
opus |
Claude Opus |
claude-sonnet-4 |
sonnet |
Claude Sonnet |
claude-haiku-4 |
haiku |
Claude Haiku |
All model IDs also accept a claude-code-cli/ prefix (e.g., claude-code-cli/claude-opus-4). Unknown models default to Opus.
OpenClaw works with this proxy out of the box. The proxy automatically maps OpenClaw tool names to Claude Code equivalents and strips conflicting tooling sections from system prompts.
Add to your Continue config:
{
"models": [{
"title": "Claude (Max)",
"provider": "openai",
"model": "claude-sonnet-4",
"apiBase": "http://localhost:3456/v1",
"apiKey": "not-needed"
}]
}from openai import OpenAI
client = OpenAI(
base_url="http://localhost:3456/v1",
api_key="not-needed" # Any value works
)
response = client.chat.completions.create(
model="claude-sonnet-4",
messages=[{"role": "user", "content": "Hello!"}]
)The proxy can run as a macOS LaunchAgent on port 3456.
Plist location: ~/Library/LaunchAgents/com.openclaw.claude-max-proxy.plist
# Start the service
launchctl bootstrap gui/$(id -u) ~/Library/LaunchAgents/com.openclaw.claude-max-proxy.plist
# Restart
launchctl kickstart -k gui/$(id -u)/com.openclaw.claude-max-proxy
# Stop
launchctl bootout gui/$(id -u)/com.openclaw.claude-max-proxy
# Check status
launchctl list com.openclaw.claude-max-proxysrc/
├── types/
│ ├── claude-cli.ts # Claude CLI JSON streaming types + type guards
│ └── openai.ts # OpenAI API types (including tool calls)
├── adapter/
│ ├── openai-to-cli.ts # Convert OpenAI requests → CLI format
│ └── cli-to-openai.ts # Convert CLI responses → OpenAI format
├── subprocess/
│ └── manager.ts # Claude CLI subprocess + OpenClaw tool mapping
├── session/
│ └── manager.ts # Session ID mapping
├── server/
│ ├── index.ts # Express server setup
│ ├── routes.ts # API route handlers
│ └── standalone.ts # Entry point
└── index.ts # Package exports
- Uses Node.js
spawn()instead of shell execution to prevent injection attacks - No API keys stored or transmitted by this proxy
- All authentication handled by Claude CLI's secure keychain storage
- Prompts passed as CLI arguments, not through shell interpretation
Install and authenticate the CLI:
npm install -g @anthropic-ai/claude-code
claude auth loginEnsure you're using -N flag with curl (disables buffering):
curl -N -X POST http://localhost:3456/v1/chat/completions ...Check that the Claude CLI is in your PATH:
which claudeContributions welcome! Please submit PRs with tests.
MIT
- Originally created by atalovesyou
- Built for use with OpenClaw
- Powered by Claude Code CLI