Skip to content

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

38 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CommandCode Cursor Proxy

OpenAI-compatible proxy for CommandCode — use 50+ AI models in Cursor, VS Code, Windsurf, and any OpenAI-compatible client.

Go Version License Version Stars


⚠️ Important Disclaimer — Please Read First

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

🚨 ToS Warning — Read Before Using

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:

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

What This Does

┌──────────┐     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.


Features

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
Rate Limited Token bucket: 4 concurrent, 30 requests/min — stays under radar
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

Quick Start (3 Steps)

Prerequisites

  • CommandCode account — Sign up at commandcode.ai (Go plan: $1/mo)
  • Go 1.26+Download Go
  • Cloudflared (for Cursor) — winget install Cloudflare.cloudflared

Step 1: Authenticate

# 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_here

The proxy auto-detects your CLI login — no extra config needed.

Step 2: Start the Proxy

# Option A: Run from source
go run main.go

# Option B: Use prebuilt binary
./bin/commandcode-cursor-proxy.exe

Default: http://127.0.0.1:55990

Step 2b: Open the Web Dashboard (easiest way)

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:

CommandCode Proxy Dashboard

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.

Step 3: Connect Your Client

🖱️ 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/v1

Note: 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.


All 50+ Supported Models

Add these model names in your client:

🧠 Claude (Anthropic)

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 (OpenAI)

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

deepseek-v4-pro deepseek-v4-flash(flash = fastest)

🌟 Gemini (Google)

gemini-3.6-flash gemini-3.5-flash gemini-3.5-flash-lite gemini-flash-lite

🎯 Kimi (Moonshot AI)

kimi-k3 kimi-k2.7-code kimi-k2.7-code-highspeed kimi-k2.6 kimi-k2.5

🌊 Qwen (Alibaba)

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

minimax-m3 minimax-m2.7 minimax-m2.5

🔮 GLM (Z AI)

glm-5.2 glm-5.2-fast glm-5.1 glm-5

⚡ StepFun

step-3.7-flash step-3.5-flash

📱 MiMo (Xiaomi)

mimo-v2.5-pro mimo-v2.5

🤖 Other Powerful Models

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)


CLI Flags

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

Authentication Methods (Priority Order)

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


Environment Variables

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

Cloudflare Tunnel — Setup for Cursor

Cursor routes requests through its cloud servers, so 127.0.0.1 won't work. You need a public HTTPS tunnel.

Option 1: Quick Tunnel (No Account)

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

Option 2: Named Tunnel (Permanent URL)

# 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-proxy

Option 3: Start Both Together

Create 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

Endpoints

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

Build from Source

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 .

Architecture

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)          │
└──────────────────────────────────────┘

Troubleshooting

"Access to private networks is forbidden" (Cursor)

Use a Cloudflare Tunnel. See Cloudflare Tunnel Setup.

"Reconnecting..." on long responses

Fixed in v2. SSE keep-alive keeps the connection alive. Ensure WriteTimeout=0 (enabled by default).

Models returning 403 / "not recognized"

Ensure the model name matches exactly from the supported list. Ensure you're using a CommandCode-supported model for your plan.

401 Unauthorized

  • Run cmd auth login in terminal
  • Or set COMMAND_CODE_API_KEY environment variable
  • Check ~/.commandcode/auth.json exists

Rate limited (429 error)

The proxy retries 3 times with backoff. If persistent, wait 1-2 minutes. The built-in rate limiter prevents bursts.

"go: command not found"

Install Go: winget install GoLang.Go


How It Works — Technical Details

Click to expand

Request Transformation

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
  }
}

Why It Works

  • Uses the same /alpha/generate endpoint 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)

Comparison with Original

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

Project Structure

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

Troubleshooting the Dashboard

Dashboard doesn't open automatically

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.

"cloudflared not found" in the tunnel card

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

Tunnel URL doesn't appear

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.

"CLI not found" when clicking Login via CLI

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.

API key not saving

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.

Stopping the proxy from the UI

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.


Credits & Acknowledgments

  • 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

📚 Research & Educational Purpose

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.


📄 License

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.

About

OpenAI-compatible proxy for CommandCode with an embedded web dashboard — 50+ models, Cloudflare tunnel management, CLI login helper, and graceful shutdown. Educational/research project.

Topics

Resources

Contributing

Stars

1 star

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages