OpenAI-compatible proxy for CommandCode — use 50+ AI models in Cursor, VS Code, Windsurf, and any OpenAI-compatible client.
This project is created for educational, research, and learning purposes only. It demonstrates:
- How to build an OpenAI-compatible API proxy in Go
- API protocol translation (OpenAI ↔ CommandCode internal format)
- SSE streaming patterns with keep-alive
- Rate limiting and request fingerprinting techniques
- Reverse engineering of undocumented API endpoints for academic study
CommandCode's founder has publicly stated that reverse-engineering their subscription/API system violates their Terms of Service. Users of similar proxy projects have faced:
- Permanent account bans (and inability to create new accounts)
- DMCA / legal action against project maintainers
- A public 48-hour ultimatum issued to a similar project (9router) before enforcement
CommandCode offers official, legitimate alternatives that we recommend for any production or heavy use:
- Provider API — https://commandcode.ai/docs/provider-api
- Headless Mode — https://commandcode.ai/docs/core-concepts/headless
This proxy is for learning and experimentation only. If you need CommandCode in a real workflow, use the official Provider API or Headless Mode instead.
Users are responsible for their own usage. This proxy does not:
- Bypass CommandCode's billing system
- Share, steal, or redistribute API keys
- Enable access to plans/features not already purchased
- Circumvent rate limits or quotas
What could happen if you use it:
- CommandCode may detect non-CLI usage and rate-limit your requests
- Your account may be flagged, suspended, or permanently banned
- CommandCode has actively pursued DMCA/legal action against similar projects
Good practices if you still choose to experiment:
- Use within normal rate limits (don't spam) — the built-in rate limiter helps
- One account per person (as per CommandCode ToS)
- Prefer the official CommandCode CLI or Provider API for any real/production use
- Do not redistribute API keys or share your proxy URL publicly
┌──────────┐ Tunnel ┌──────────────────┐ Official API ┌───────────────────┐
│ Cursor │ ───────────────→│ Go Proxy (:55990)│────────────────────→│ api.commandcode.ai│
│ VSCode │ cloudflared │ Format Translator│ /alpha/generate │ (CommandCode) │
│ CLI │ └──────────────────┘ └───────────────────┘
└──────────┘
This proxy translates OpenAI-compatible chat completion requests into the format used by CommandCode's CLI, enabling any OpenAI-compatible client to use CommandCode models.
| Feature | Description |
|---|---|
| 50+ Models | Claude, GPT, DeepSeek, Gemini, Kimi, Qwen, MiniMax, Grok, GLM, MiMo, and more |
| Multiple Auth | 4 ways — Header, Env Var, Auto-detect CLI token, CLI flag |
| Images Supported | Base64 data URLs and image URLs forwarded to the model |
| No Timeouts | SSE keep-alive pings every 15s — no "reconnecting" errors |
| Large Payload Handling | 120s read timeouts to effortlessly handle 30MB+ contexts & images |
| Auto-Compaction | Transparent token compression keeps huge sessions <262k limit without crashing |
| Rate Limited | Token bucket: 4 concurrent, 30 requests/min — stays under radar |
| Workspace Ingestion | Ingests real Git branch/status & AGENTS.md context natively |
| Auto Retry | Exponential backoff on 429 errors (5s → 25s → 45s) |
| CORS Enabled | Works with browser extensions and desktop apps |
| Self-updating | Checks for new CommandCode CLI version automatically |
| Metrics | /metrics endpoint for monitoring |
- CommandCode account — Sign up at commandcode.ai (Go plan: $1/mo)
- Go 1.26+ — Download Go
- Cloudflared (for Cursor) —
winget install Cloudflare.cloudflared
# Option A: Login via CLI (recommended — zero config)
npm i -g command-code
cmd auth login
# Option B: Set environment variable
export COMMAND_CODE_API_KEY=user_your_key_here
# Option C: API key flag
./bin/commandcode-cursor-proxy.exe -api-key user_your_key_hereThe proxy auto-detects your CLI login — no extra config needed.
# Option A: Run from source
go run main.go
# Option B: Use prebuilt binary
./bin/commandcode-cursor-proxy.exeDefault: http://127.0.0.1:55990
When you run the EXE, your browser auto-opens the dashboard at http://127.0.0.1:55990/ui. From there you can configure everything without touching the command line:
The dashboard lets you:
- 🔑 Save your API key — stored locally at
~/.commandcode-cursor-proxy/config.json(never baked into the binary) - 🧭 Follow the Setup Guide — step-by-step checklist that detects what's done
- 🌐 Start/stop the Cloudflare tunnel — URL auto-detected and shown with the exact Cursor Base URL to paste
- 📊 See live status — proxy, auth source, CLI login, cloudflared install
- 🧠 Browse 50+ models — click any model to copy its name
- 🧪 Run a quick test — verify the proxy works with one click
- 🌙 Toggle dark/light theme — saved to your browser
- ⏹ Stop the proxy — graceful shutdown from the UI
You can also launch the CLI login flow (cmd auth login) directly from the dashboard if the CommandCode CLI is installed.
🖱️ Cursor IDE
Cursor Settings → Models → Enable "Override OpenAI Base URL"
Base URL: http://127.0.0.1:55990/v1 ← for local use
OR
https://your-tunnel.trycloudflare.com/v1 ← if using tunnel
API Key: your-commandcode-api-key
Add models: deepseek-v4-flash, claude-sonnet-5, gpt-5.5, etc.
Cursor requires public HTTPS. Create a tunnel:
# Terminal 1: Start proxy
./bin/commandcode-cursor-proxy.exe
# Terminal 2: Start Cloudflare tunnel
cloudflared tunnel --url http://127.0.0.1:55990
# Copy the URL shown (e.g., https://something.trycloudflare.com)
# Paste in Cursor: https://something.trycloudflare.com/v1Note: Free Cloudflare tunnel URLs change on restart. For a permanent URL, create a free Cloudflare account and use a named tunnel.
💻 VS Code (Cline / Roo Code / Continue)
API Provider: OpenAI Compatible
Base URL: http://127.0.0.1:55990/v1
API Key: your-commandcode-api-key
Model: deepseek-v4-flash
⌨️ Claude Code
export ANTHROPIC_BASE_URL=http://127.0.0.1:55990/v1
export ANTHROPIC_API_KEY=your-commandcode-api-key
claude🖥️ Terminal (curl)
curl http://127.0.0.1:55990/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer your-key" \
-d '{
"model": "deepseek-v4-flash",
"messages": [{"role": "user", "content": "Hello!"}],
"stream": true
}'📝 Aider
aider --openai-api-base http://127.0.0.1:55990/v1 \
--openai-api-key your-key \
--model deepseek-v4-flash🌐 Windsurf
Add custom provider in AI Settings with Base URL http://127.0.0.1:55990/v1.
Add these model names in your client:
claude-sonnet-5 claude-opus-5 claude-haiku-4-5 claude-fable-5 claude-sonnet-4-6 claude-opus-4-8 claude-opus-4-7
gpt-5.6-terra gpt-5.6-sol gpt-5.6-luna gpt-5.5 gpt-5.4 gpt-5.4-mini gpt-5.3-codex
deepseek-v4-pro deepseek-v4-flash ⚡ (flash = fastest)
gemini-3.6-flash gemini-3.5-flash gemini-3.5-flash-lite gemini-flash-lite
kimi-k3 kimi-k2.7-code kimi-k2.7-code-highspeed kimi-k2.6 kimi-k2.5
qwen-3.8-max qwen-3.7-max qwen-3.7-plus qwen-3.7-flash qwen-3.6-max qwen-3.6-plus
minimax-m3 minimax-m2.7 minimax-m2.5
glm-5.2 glm-5.2-fast glm-5.1 glm-5
step-3.7-flash step-3.5-flash
mimo-v2.5-pro mimo-v2.5
muse-spark-1.2 muse-spark-1.1 muse-spark-1.2-contributor (Meta)
laguna-s-2.1-free (Poolside — 118B open-weight)
grok-4.5 (xAI)
nemotron-3-ultra (NVIDIA — 550B)
fugu-ultra (Sakana AI)
hy3-paid (Tencent)
inkling inkling-small (Thinking Machines)
commandcode-cursor-proxy.exe [flags]| Flag | Default | Description |
|---|---|---|
-host |
127.0.0.1 |
Host to bind to (0.0.0.0 for LAN) |
-port |
55990 |
Server port |
-api-key |
(auto) | Manual API key (auto-detected if not set) |
-version |
— | Print version and exit |
The proxy tries these in order:
| Priority | Method | Example |
|---|---|---|
| 1 | Authorization: Bearer header |
Client sends key in request |
| 2 | COMMAND_CODE_API_KEY env var |
export COMMAND_CODE_API_KEY=user_... |
| 3 | ~/.commandcode/auth.json |
Auto-detected from cmd auth login |
| 4 | -api-key flag |
CLI flag fallback |
Quick test: curl http://127.0.0.1:55990/health → {"status":"ok"}
You can configure the proxy using a .env file in the same directory as the executable, or by setting system environment variables. (See .env.example).
| Variable | Purpose |
|---|---|
COMMAND_CODE_API_KEY |
Your CommandCode API key |
COMMANDCODE_PROXY_DEBUG |
Set to 1 for verbose logging |
COMMANDCODE_SKIP_UPDATES |
Skip auto-update check |
PORT |
Set a custom port (default: 55990) |
HOST |
Set a custom host (default: 127.0.0.1) |
- Large Payload Safety: The proxy uses a custom
120sread timeout to ensure that massive contexts (like 30MB base64 images from Cursor's Vision mode) don't cause connection drops over slow tunnels. - Auto-Compaction: If your context approaches the 262,000 token limit, the proxy will transparently compress older tool responses in the background. It aggressively truncates intermediate payloads without dropping messages, ensuring the rigid OpenAI API structure remains perfectly valid.
- CLI Parity & Fingerprinting: The proxy acts identical to the official CLI by natively reading your project's
.gitstatus, current branch, recent commits, andAGENTS.mdcontext files. This ensures maximum compatibility and feature parity on the backend. - Leak-free Process Management: Subprocesses (like
gitcontext scrapers) are strictly bound tocontext.WithTimeoutensuring zero background zombie processes if git hangs.
Cursor routes requests through its cloud servers, so 127.0.0.1 won't work. You need a public HTTPS tunnel.
# Terminal 1
./bin/commandcode-cursor-proxy.exe
# Terminal 2
cloudflared tunnel --url http://127.0.0.1:55990
# Copy the URL: https://something.trycloudflare.com
# Cursor Base URL: https://something.trycloudflare.com/v1
⚠️ URL changes every restart. Okay for testing.
# One-time setup
cloudflared tunnel login
cloudflared tunnel create cursor-proxy
# Create config.yml
# tunnel: <tunnel-id>
# credentials-file: /path/to/<tunnel-id>.json
# ingress:
# - hostname: proxy.yourdomain.com
# service: http://127.0.0.1:55990
# - service: http_status:404
cloudflared tunnel route dns cursor-proxy proxy.yourdomain.com
cloudflared tunnel run cursor-proxyCreate start.bat (Windows):
@echo off
start "Proxy" cmd /k "bin\commandcode-cursor-proxy.exe"
timeout /t 3 /nobreak >nul
start "Tunnel" cmd /k "cloudflared tunnel --url http://127.0.0.1:55990"
pause| Method | Path | Purpose |
|---|---|---|
POST |
/v1/chat/completions |
Chat with streaming & non-streaming |
POST |
/chat/completions |
Convenience alias |
POST |
/v1/responses |
OpenAI Responses API format |
POST |
/v1/messages |
Anthropic-compatible messages format |
GET |
/v1/models |
List 50+ models |
GET |
/health |
Health check ({"status":"ok"}) |
GET |
/metrics |
Request stats & uptime |
GET |
/balance |
Billing/credits check |
GET |
/ui |
Web dashboard (browser UI) |
GET |
/ui/api/status |
Status JSON (proxy, auth, cloudflared) |
GET/POST |
/ui/api/config |
Read/save API key (local file) |
POST |
/ui/api/cli-login |
Launch cmd auth login in a terminal |
GET/POST |
/ui/api/tunnel |
Start/stop cloudflared, get URL + logs |
POST |
/ui/api/test |
Send a test chat request |
POST |
/ui/api/shutdown |
Gracefully stop the proxy from the UI |
git clone https://github.com/Nir-Bhay/commandcode-cursor-proxy.git
cd commandcode-cursor-proxy
go build -o bin/commandcode-cursor-proxy.exe .
# Cross-compile
GOOS=linux GOARCH=amd64 go build -o bin/commandcode-cursor-proxy .Client Request (OpenAI format)
│
▼
┌──────────────────────────────────────┐
│ commandcode-cursor-proxy (:55990) │
│ │
│ 1. Auth: resolves API key │
│ 2. Model: maps short name → full │
│ 3. Convert: OpenAI → CommandCode │
│ 4. Fingerprint: detect git/memory │
│ 5. Rate limit: token bucket │
│ 6. Forward → api.commandcode.ai │
│ 7. Stream back: CC → OpenAI SSE │
│ (15s keep-alive pings) │
└──────────────────────────────────────┘
│
▼
┌──────────────────────────────────────┐
│ api.commandcode.ai/alpha/generate │
│ (CommandCode CLI endpoint) │
└──────────────────────────────────────┘
Use a Cloudflare Tunnel. See Cloudflare Tunnel Setup.
Fixed in v2. SSE keep-alive keeps the connection alive. Ensure WriteTimeout=0 (enabled by default).
Ensure the model name matches exactly from the supported list. Ensure you're using a CommandCode-supported model for your plan.
- Run
cmd auth loginin terminal - Or set
COMMAND_CODE_API_KEYenvironment variable - Check
~/.commandcode/auth.jsonexists
The proxy retries 3 times with backoff. If persistent, wait 1-2 minutes. The built-in rate limiter prevents bursts.
Install Go: winget install GoLang.Go
Click to expand
OpenAI Chat Request:
{
"model": "deepseek-v4-flash",
"messages": [{"role": "user", "content": "Hello"}],
"stream": true
}
→ Proxy transforms to:
CommandCode Request:
{
"config": {
"workingDir": "/actual/dir",
"date": "2026-08-06",
"environment": "cli",
"isGitRepo": true,
"currentBranch": "main",
...
},
"permissionMode": "default",
"params": {
"model": "deepseek/deepseek-v4-flash",
"system": "...",
"messages": [...],
"stream": true
}
}
- Uses the same
/alpha/generateendpoint the CommandCode CLI (cmd) uses - Sends CLI-identical request format (config, memory, permissionMode)
- Auto-detects git repo, branch, status like real CLI
- Matches CLI headers (
x-command-code-version,User-Agent) - Rate-limits to natural human patterns (4 concurrent, 30 RPM with jitter)
| Feature | Original v1.0.8 | This v2.0.0 |
|---|---|---|
| Models | 14 | 50+ |
| Auth Methods | 2 | 4 |
| Images | Broken (text fallback) | Full support |
| SSE Keep-Alive | No | 15s pings |
| Rate Limiting | No | Token bucket |
| 429 Retry | No | Exponential backoff |
| CLI Fingerprinting | No | Git/memory detection |
| CORS | No | All origins |
| WriteTimeout | Default | 0 (SSE-safe) |
| Scanner Buffer | 1MB | 10MB |
| Metrics Endpoint | No | Yes |
| Graceful Shutdown | No | Yes (UI + signal) |
| Body Size Limit | Unlimited | 50MB |
| Web Dashboard | No | Yes (embedded at /ui) |
| Dark/Light Theme | No | Yes (saved) |
| Cloudflare Tunnel Mgmt | No | Yes (start/stop/URL detect) |
| CLI Login Helper | No | Yes (launches cmd auth login) |
| Local Config Storage | No | Yes (~/.commandcode-cursor-proxy/) |
proxy-src/
├── main.go # Entry point, CLI flags, browser auto-open
├── internal/
│ ├── api/ # CommandCode + OpenAI type definitions
│ ├── auth/ # API key resolution (header/env/CLI/flag)
│ ├── config/ # Local config file (API key storage)
│ ├── fingerprint/ # Git/memory detection (CLI-identical requests)
│ ├── modelcatalog/ # Model name mapping
│ ├── proxy/ # Core proxy: convert, stream, retry, rate-limit
│ ├── server/ # HTTP server, middleware, graceful shutdown
│ ├── ui/ # Embedded web dashboard
│ │ ├── handler.go # UI API handlers + tunnel management
│ │ ├── dashboard.html # Dashboard markup
│ │ ├── style.css # Dark/light theme styles
│ │ └── app.js # Dashboard logic
│ ├── update/ # CLI version check
│ └── version/ # npm registry version fetch
└── bin/ # Built binaries
Open http://127.0.0.1:55990/ui manually in your browser. The auto-open is best-effort and may fail on some Linux setups without xdg-open.
Install it:
- Windows:
winget install Cloudflare.cloudflared - macOS:
brew install cloudflared - Linux: see Cloudflare docs
The dashboard auto-detects it (including the default Windows path C:\Program Files (x86)\cloudflared\).
Wait ~10 seconds after clicking Start — cloudflared needs to request a quick tunnel. The URL appears in the tunnel logs panel as soon as it's assigned. The proxy reads both stdout and stderr to catch it.
Install the CommandCode CLI first: npm i -g command-code, then click the button again. It will open a terminal window running cmd auth login.
The key is stored at ~/.commandcode-cursor-proxy/config.json with 0600 permissions. If your home directory isn't writable, the save will fail — check the toast notification for the error.
Click the red Stop button in the top bar. The proxy shuts down gracefully (finishes in-flight requests, stops the tunnel, then exits). You'll need to run the EXE again to restart.
- Original proxy by dev2k6
- Enhanced and maintained by Nir-Bhay
- CommandCode is a product of Langbase, Inc.
- Thanks to the open-source community for feedback and contributions
This project is intended as a study of:
- API reverse engineering and protocol translation
- OpenAI-compatible server implementation in Go
- SSE (Server-Sent Events) streaming patterns
- Rate limiting algorithms (token bucket)
- Request fingerprinting and bot detection
- CLI authentication token management
- Go HTTP server best practices
If you're learning about any of these topics, the source code in internal/ is well-commented and designed for study.
MIT License — see LICENSE file.
Note: This project does NOT include any CommandCode proprietary code, CLI binaries, or copyrighted materials. It is an independent format-translation layer that calls CommandCode's public API using the user's own credentials.
⭐ Star this repo if you found it useful!
🔧 Contributions welcome — PRs, issues, and suggestions appreciated.
📧 Questions? Open an issue on GitHub.
