@rizqme/code-router
v0.1.3
Published
Dual provider router for Claude MAX and ChatGPT subscriptions.
Maintainers
Readme
code-router
██████╗ ██████╗
██╔════╝ ██╔══██╗
██║ ██████╔╝ CODE
██║ ██╔══██╗ ROUTER
╚██████╗ ██║ ██║
╚═════╝ ╚═╝ ╚═╝code-router lets you use Claude MAX and ChatGPT subscription auth behind local API endpoints that speak Anthropic, OpenAI, and OpenRouter-style model naming.
It has two modes:
- interactive terminal UI
- direct CLI commands like
serve,verify, andmodels
Personal and research use only. Do not use this project in ways that violate the Terms of Service or Terms and Conditions of Anthropic or OpenAI. You are responsible for how you authenticate, route, and use subscription-backed services.
Install
Global install:
npm install -g @rizqme/code-routerRun without installing:
npx @rizqme/code-routerQuick start
Open the interactive CLI:
code-routerStart the local router server:
code-router serveVerify saved subscriptions:
code-router verifyList models:
code-router modelsCommand overview
code-router
code-router serve [router flags]
code-router verify [--provider claude|openai|all] [--json]
code-router models [--provider claude|openai|openrouter|all] [--json]
code-router auth <claude|openai|status>
code-router logout <claude|openai|all>
code-router status [--json]Examples:
code-router
code-router serve --port 3344 --verbose
code-router verify
code-router models --provider openrouter
code-router auth claude
code-router auth openai
code-router logout allInteractive vs non-interactive
Default behavior:
- if the terminal supports Ink,
code-routeropens the interactive TUI - if the terminal does not support interactive mode,
code-routerfalls back to text output
Force behavior:
code-router --interactive
code-router --no-interactiveIf you force interactive mode in a non-interactive terminal, the command exits with an error.
Authentication
Supported auth:
- Claude MAX OAuth
- ChatGPT OAuth
Ways to authenticate:
- use the interactive UI:
code-router - use direct commands:
code-router auth claude
code-router auth openai
code-router auth statusStored credentials:
- Claude:
.oauth-tokens.json - ChatGPT:
.chatgpt-api-key.json
Clear saved credentials:
code-router logout claude
code-router logout openai
code-router logout allServing the local router
Start the server:
code-router servePass router flags through directly:
code-router serve --port 8080
code-router serve --verbose
code-router serve --minimal
code-router serve --quiet
code-router serve --disable-bearer-passthroughThe local server exposes:
POST /v1/messagesPOST /v1/chat/completionsPOST /v1/responsesGET /v1/modelsGET /health
Default base URL:
http://localhost:3344OpenAI-compatible base URL:
http://localhost:3344/v1Model listing
List all models:
code-router modelsFilter by provider:
code-router models --provider claude
code-router models --provider openai
code-router models --provider openrouterJSON output:
code-router models --jsonopenrouter output uses OpenRouter-style model ids such as:
openai/gpt-5.4anthropic/claude-sonnet-4-6
Subscription verification
Verify both subscriptions:
code-router verifyVerify one side only:
code-router verify --provider claude
code-router verify --provider openaiJSON output:
code-router verify --jsonRouter behavior
The router supports both request formats:
- Anthropic-style requests
- OpenAI-style requests
It also supports OpenRouter-style model names on OpenAI-format paths.
Examples:
gpt-5.4claude-sonnet-4-6openai/gpt-5.4anthropic/claude-sonnet-4-6
When only one subscription is available:
- Claude-family requests can be mapped to the latest GPT model
- GPT-family requests can be mapped to the latest Sonnet model
The /v1/models endpoint is served from in-memory cached model data when available.
API examples
Anthropic-style request:
curl -X POST http://localhost:3344/v1/messages \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-6",
"max_tokens": 64,
"messages": [
{"role": "user", "content": "Reply with exactly: ok"}
]
}'OpenAI-style request:
curl -X POST http://localhost:3344/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-5.4",
"messages": [
{"role": "user", "content": "Reply with exactly: ok"}
]
}'OpenRouter-style model name:
curl -X POST http://localhost:3344/v1/chat/completions \
-H "Content-Type: application/json" \
-d '{
"model": "anthropic/claude-sonnet-4-6",
"messages": [
{"role": "user", "content": "Reply with exactly: ok"}
]
}'Common commands
Show current status:
code-router statusShow JSON status:
code-router status --jsonStart with npx:
npx code-router
npx code-router serve
npx code-router verifyNotes
code-routeris designed for local use- subscription-backed endpoints and auth flows can change over time
- if auth breaks, re-run:
code-router auth claude
code-router auth openaiLicense
MIT
Author
Ahmad Rizqi Meydiarso
