
Product
Introducing Data Exports
Export Socket alert data to your own cloud storage in JSON, CSV, or Parquet, with flexible snapshot or incremental delivery.
anthropic-max-router
Advanced tools
HTTP proxy router for using Anthropic MAX Plan (flat-rate billing) with any AI tool

Educational proof-of-concept and practical tools for using Anthropic's Claude MAX Plan with OAuth authentication
A menu-driven tool to test OAuth flows, understand authentication, and experiment with API requests.
npm start
A standalone HTTP proxy that lets ANY AI tool use your MAX Plan subscription via http://localhost:3000.
npx anthropic-max-router
Full technical documentation: OAuth PKCE flow, system prompt validation, token management, and API patterns.
See ANTHROPIC-MAX-PLAN-IMPLEMENTATION-GUIDE.md
This repository provides both practical tools and complete documentation for using Anthropic's Claude MAX subscription plans with your own code.
Why MAX Plan? Flat-rate billing instead of pay-per-token. Perfect for high-volume AI development.
Special thanks to OpenCode - studying its OAuth implementation made this project possible.
⚠️ EDUCATIONAL AND RESEARCH PURPOSES
This project is provided for educational, research, and entertainment purposes only. It is not affiliated with, endorsed by, or sponsored by Anthropic PBC. Use of this software is at your own risk. The authors and contributors make no warranties and accept no liability for any damages or issues arising from use of this code. Users are responsible for ensuring their use complies with Anthropic's Terms of Service and all applicable laws. This software is provided "as-is" without any express or implied warranties.
The fastest way to get started - no git clone, no npm install needed:
npx anthropic-max-router
That's it! The router will:
npx anthropic-max-router --help # Show all options
npx anthropic-max-router --port 8080 # Custom port
npx anthropic-max-router --verbose # Full request logging
npx anthropic-max-router -p 8080 --minimal # Combine options
# Run directly from GitHub repository
npx github:nsxdavid/anthropic-max-router
# With options
npx github:nsxdavid/anthropic-max-router --port 8080 --verbose
# Clone the repository
git clone https://github.com/nsxdavid/anthropic-max-router
cd anthropic-max-router
npm install
# Run the router
npm run router
# OR run the interactive CLI
npm start
A menu-driven application for testing, learning, and debugging OAuth flows.
npm start
You'll see an interactive menu:
╔════════════════════════════════════════════════════════════╗
║ Anthropic MAX Plan OAuth CLI ║
╚════════════════════════════════════════════════════════════╝
1. Authenticate (OAuth flow)
2. Refresh access token
3. Send a chat message
4. Logout (delete tokens)
5. Proof of MAX Plan validation
6. Exit
src/
├── cli.ts # Interactive menu
├── oauth.ts # OAuth PKCE flow
├── client.ts # API client with validation
├── token-manager.ts # Token storage/refresh
└── types.ts # TypeScript definitions
A standalone HTTP proxy server that lets any AI tool or application use your MAX Plan subscription. The only requirement is that the tool/app supports setting the Anthropic API base URL. Most do. If the one you are trying to use this with does not, complain to them... they will probably fix it. :)
┌─────────────────────┐
│ Your AI Tool │
│ (any application) │
└──────────┬──────────┘
│ http://localhost:3000
▼
┌─────────────────────────────────────┐
│ Router (This Application) │
│ ├─ OAuth authentication │
│ ├─ System prompt injection │
│ ├─ Token auto-refresh │
│ └─ Request logging │
└──────────┬──────────────────────────┘
│ Authenticated requests
▼
┌─────────────────────┐
│ Anthropic MAX API │
│ (Flat-rate billing)│
└─────────────────────┘
# Start router (default: port 3000, medium verbosity)
npm run router
# With options
npm run router -- --port 8080 # Custom port
npm run router -- --verbose # Full request/response logging
npm run router -- --minimal # One line per request
npm run router -- --quiet # No request logging
npm run router -- -p 8080 --verbose # Combine options
First run: Router prompts you to authenticate via OAuth. Follow the instructions.
Subsequent runs: Router starts immediately and auto-refreshes tokens.
| Option | Short | Description |
|---|---|---|
--help | -h | Show help message |
--version | -v | Show version number |
--port PORT | -p | Set port (default: 3000) |
--quiet | -q | No request logging |
--minimal | -m | One line per request |
| (default) | Medium verbosity - summary per request | |
--verbose | -V | Full request/response bodies |
Environment variable: ROUTER_PORT=8080 npm run router
Minimal (-m) - One line per request:
[10:30:45] ✓ 200 claude-sonnet-4-5 (in:28 out:19)
[10:31:12] ✓ 200 claude-sonnet-4-5 (in:300 out:500)
Medium (default) - Request summary:
[2025-11-02T10:30:45.123Z] [abc123] Incoming request
Model: claude-sonnet-4-5
Max tokens: 1000
✓ Injected required system prompt
✓ OAuth token validated
→ Forwarding to Anthropic API...
✓ Success (200)
Tokens: input=28, output=19
Verbose (-V) - Full JSON request/response bodies for debugging.
Quiet (-q) - No request logging (only startup messages and errors).
POST /v1/messages - Main proxy endpoint (standard Anthropic API format)
GET /health - Health check
curl http://localhost:3000/health
# Returns: {"status":"ok","service":"anthropic-max-plan-router"}
Send a test request:
PowerShell:
curl -X POST http://localhost:3000/v1/messages `
-H "Content-Type: application/json" `
-d '{"model":"claude-sonnet-4-5","max_tokens":50,"messages":[{"role":"user","content":"Say hello in one short sentence."}]}'
Bash/Linux/Mac:
curl -X POST http://localhost:3000/v1/messages \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 50,
"messages": [
{"role": "user", "content": "Say hello in one short sentence."}
]
}'
You should see the request logged in your router terminal and get a JSON response from Claude.
Configure any AI tool that supports custom base URLs to point to:
http://localhost:3000
🔑 Important Note About API Keys
The router handles OAuth authentication, so the API key doesn't matter. If your tool requires an API key, use any string it accepts - many tools don't even validate the format. Common values:
"not-used","dummy","sk-ant-1234", etc.The key is never sent to Anthropic - the router strips it and replaces it with OAuth credentials.
JavaScript/TypeScript:
const client = new AnthropicClient({
baseURL: 'http://localhost:3000',
// No API key needed - router handles authentication
});
Python:
import anthropic
client = anthropic.Anthropic(
api_key="not-used", # Can be anything - router handles auth
base_url="http://localhost:3000",
)
response = client.messages.create(
model="claude-sonnet-4-5",
max_tokens=1000,
messages=[{"role": "user", "content": "Hello!"}]
)
Anthropic's MAX Plan requires this exact system prompt as the first element:
"You are Claude Code, Anthropic's official CLI for Claude."
The router:
src/router/
├── server.ts # Express server with CLI argument parsing
├── middleware.ts # System prompt injection logic
└── logger.ts # Verbosity-aware logging
"No OAuth tokens found" → Router will automatically prompt you to authenticate on first run.
Port already in use
→ Use npm run router -- --port 8080
Authentication fails
→ Delete .oauth-tokens.json and restart. Router will re-authenticate.
Want to see what's happening?
→ Use npm run router -- --verbose
Complete technical documentation covering the internals:
📖 ANTHROPIC-MAX-PLAN-IMPLEMENTATION-GUIDE.md
This guide is essential reading for understanding how the system works under the hood.
code#statecode#state back.oauth-tokens.json.oauth-tokens.jsonDelete .oauth-tokens.json and restart. The application will prompt for re-authentication.
anthropic-max-router/
├── src/
│ ├── cli.ts # Interactive CLI application
│ ├── oauth.ts # OAuth PKCE flow implementation
│ ├── client.ts # API client with validation
│ ├── token-manager.ts # Token storage and refresh
│ ├── types.ts # TypeScript type definitions
│ └── router/
│ ├── server.ts # Router with CLI argument parsing
│ ├── middleware.ts # System prompt injection
│ └── logger.ts # Verbosity-aware logging
├── examples/
│ └── test-router.js # Example router usage
├── ANTHROPIC-MAX-PLAN-IMPLEMENTATION-GUIDE.md # Technical docs
├── CHANGELOG.md
├── README.md # This file
└── package.json
nsxdavid (David Whatley)
MIT
This demonstrates Anthropic's official OAuth flow with MAX subscription. All authentication uses Anthropic's official endpoints. This is the same OAuth flow used by Claude Code.
Anthropic may change OAuth requirements at any time. Tested and verified working as of November 2nd, 2025.
FAQs
Dual API router (Anthropic + OpenAI compatible) for Claude MAX Plan - Use flat-rate billing with ANY AI tool: OpenAI SDK, LangChain, Anthropic SDK, and more
We found that anthropic-max-router demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Product
Export Socket alert data to your own cloud storage in JSON, CSV, or Parquet, with flexible snapshot or incremental delivery.

Research
/Security News
Bitwarden CLI 2026.4.0 was compromised in the Checkmarx supply chain campaign after attackers abused a GitHub Action in Bitwarden’s CI/CD pipeline.

Research
/Security News
Docker and Socket have uncovered malicious Checkmarx KICS images and suspicious code extension releases in a broader supply chain compromise.