Lightweight, high-performance Go gateway for CodeBuddy Global API. Single binary, zero runtime deps, built for CLI terminal.
- 🚀 Single Binary — no Node.js, no Python, no runtime dependencies
- 🔄 Smart Key Rotation — round-robin + auto-retry on 401/403/429/5xx
- 🌐 Proxy Support — HTTP, HTTPS, SOCKS5, SOCKS5H via
.env - 💻 TUI Dashboard — live request log, key pool status, usage stats
- 🤖 Auto Setup — interactive wizard when API key is missing
- 🔐 Router Auth — auto-generated per-machine
rtr_key - 🔁 Setup Retry — re-enter keys on validation failure, no restart needed
- 📡 Connection Test — validates API key on startup
- 🎯 OpenAI-Compatible — drop-in for any OpenAI-compatible tool
sudo cp buddy /usr/local/bin/buddy
sudo chmod +x /usr/local/bin/buddybuddyscreen -S buddy buddyCtrl+AthenD— detach (buddy keeps running)screen -r buddy— reattachscreen -ls— list sessions
If no API key is detected, the setup wizard runs automatically:
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
🚀 CodeBuddy CLI Gateway — Setup
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
Enter your CodeBuddy API key(s) (ck_...)
Press Enter on an empty line when done.
Key: ck_your_api_key_here
Checking... ✅ key valid, CodeBuddy reachable
Key #1 saved.
Key:
If the API key fails validation, you are prompted to re-enter — no restart needed:
🔍 Validating CodeBuddy API key... ❌ invalid key (401/403)
⚠️ Key validation failed. Press Enter to re-enter keys, or type 'q' to quit.
| Variable | Default | Description |
|---|---|---|
PORT |
2069 |
Listening port |
API_KEYS |
— | Comma-separated CodeBuddy API keys (ck_...) |
PROXY |
(empty/direct) | HTTP/HTTPS/SOCKS5 proxy URL |
Router Auth Key (
rtr_...) is auto-generated per-machine usinghostname + machine-id. Stable across restarts, unique per device. No.enventry needed.
PORT=2069
API_KEYS=ck_your_key_here,ck_another_key_here
PROXY=socks5://user:pass@host:1080PROXY=http://proxy.example.com:8080
PROXY=https://user:pass@proxy.example.com:443
PROXY=socks5://127.0.0.1:1080
PROXY=socks5://user:pass@proxy.example.com:1080| Endpoint | Method | Description |
|---|---|---|
/health |
GET | Health check + key count + model count |
/v1/models |
GET | List all 36 available models |
/v1/chat/completions |
POST | Forward request to CodeBuddy API |
curl http://localhost:2069/healthcurl http://localhost:2069/v1/chat/completions \
-H "Content-Type: application/json" \
-H "Authorization: Bearer rtr_..." \
-d '{
"model": "claude-sonnet-4.6",
"messages": [
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": "Hello!"}
],
"stream": true
}'Click to expand full model list (36 models)
Claude
claude-opus-4.7-1mclaude-opus-4.6claude-sonnet-4.6claude-haiku-4.5
GPT
gpt-5.6-lunagpt-5.6-solgpt-5.6-terragpt-5.5gpt-5.4gpt-5.3-codexgpt-5.2-codexgpt-5.2gpt-5.1-codex-maxgpt-5.1-codex-minigpt-5.1-codexgpt-5.1gpt-5-codexgpt-4.1
Gemini
gemini-3.5-flashgemini-3.1-progemini-3.1-flash-litegemini-3.0-progemini-3.0-flashgemini-2.5-progemini-2.5-flash
GLM
glm-5.2glm-5.1glm-5v-turboglm-5.0glm-4.6
Kimi
kimi-k3kimi-k2.6kimi-k2.5
DeepSeek
deepseek-v3.2
MiniMax
minimax-m3
Reasoning
o4-mini
codebuddy-router/
├── main.go # Entry point + setup + banner
├── internal/
│ ├── config/
│ │ └── config.go # .env loader + machine key generator
│ ├── router/
│ │ ├── models.go # 36 model registry
│ │ ├── proxy.go # HTTP forwarding + proxy
│ │ ├── rotate.go # Round-robin key pool
│ │ └── server.go # HTTP handlers + auth
│ └── tui/
│ └── app.go # Live TUI dashboard
├── .env # Config (never commit)
└── go.mod / go.sum
CodeBuddy CLI Gateway
───────────────────────────────────────────────────────────────
Base URL : http://0.0.0.0:2069/v1
Models : 36
Keys : 1 (1 active)
API Key : rtr_16c9369819187db59273446de1a4eaf84dd3191e14d77d21
Log
Total request: 142 ✅: 138 ❌: 4 ⚡: 12/min
07:54:12 200 3.2s claude-sonnet-4.6 k1
07:54:10 429 1.8s gpt-5.5 k1 rate limit
07:54:08 200 5.1s claude-opus-4.7-1m k1
07:54:05 200 2.7s gemini-3.5-flash k1
07:54:02 200 4.0s gpt-5.4 k1
07:53:58 200 3.5s claude-sonnet-4.6 k1
07:53:55 200 2.9s claude-haiku-4.5 k1
07:53:50 200 1.8s gpt-5.1 k1
[m] minimize [l] clear [q] quit
Keybinds: q Quit · l Clear Log · m Minimize/Expand
# Claude Code
claude code --baseUrl http://localhost:2069/v1 --apiKey $(buddy key)
# OpenCode / Any OpenAI-Compatible tool
export OPENAI_API_BASE=http://localhost:2069/v1
export OPENAI_API_KEY=rtr_...| Issue | Fix |
|---|---|
| Port conflict | Change PORT in .env |
unauthorized: invalid router key |
Restart buddy — RouterKey is deterministic per-machine |
all keys exhausted |
API keys expired — test with curl first |
invalid key (401/403) |
Re-enter a valid key — setup wizard will prompt automatically |
| Proxy failed | Verify: curl -x socks5://... https://www.codebuddy.ai |
| TUI not showing (headless) | Normal — no TTY, falls back to log mode |