mirror of
https://github.com/Nezumi-2711/9router.git
synced 2026-09-22 13:38:31 +00:00
feat(headroom): add proxy lifecycle management + dashboard UI
Build on the optional Headroom Token Saver from Carmelo Campos
(PR: feat: add optional Headroom token saver). Add managed start/stop
of the local headroom proxy from the dashboard, install detection,
status probing, and a simplified Token Saver UI.
- detect headroom CLI + python>=3.10, probe proxy /health
- spawn/stop proxy as a detached, pid-tracked process
- /api/headroom/{status,start,stop} routes, gated local-only in dashboardGuard
- one-click Start/Stop Headroom modal, no manual config needed
- claude<->openai shape conversion for /v1/compress via 9router translators
Thanks to Carmelo Campos (@carmelogunsroses) for the original Headroom integration.
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -407,6 +407,7 @@ Default URLs:
|
||||
| Feature | What It Does | Why It Matters |
|
||||
|---------|--------------|----------------|
|
||||
| 🚀 **RTK Token Saver** ([RTK](https://github.com/rtk-ai/rtk) ⭐40K) | Compress tool outputs (`git diff`, `grep`, `ls`, `tree`...) before sending to LLM | Save **20-40% input tokens** per request |
|
||||
| 🧠 **Headroom Token Saver** ([Headroom](https://github.com/chopratejas/headroom)) | Optional external `/v1/compress` proxy before provider routing | Save more context tokens without changing clients |
|
||||
| 🪨 **Caveman Mode** ([Caveman](https://github.com/JuliusBrussee/caveman) ⭐52K) | Inject caveman-speak prompt → LLM replies terse, technical substance preserved | Save **up to 65% output tokens** |
|
||||
| 🎯 **Smart 3-Tier Fallback** | Auto-route: Subscription → Cheap → Free | Never stop coding, zero downtime |
|
||||
| 📊 **Real-Time Quota Tracking** | Live token count + reset countdown | Maximize subscription value |
|
||||
@@ -437,6 +438,35 @@ Without RTK: 47K tokens sent to LLM
|
||||
With RTK: 28K tokens sent to LLM (40% saved · same context · same answer)
|
||||
```
|
||||
|
||||
### 🧠 Headroom Token Saver
|
||||
|
||||
Headroom is optional and runs separately. 9Router calls Headroom's local `/v1/compress` endpoint, then keeps normal routing, fallback, auth, and usage tracking:
|
||||
|
||||
```
|
||||
Client → 9Router → Headroom /v1/compress → 9Router → provider
|
||||
```
|
||||
|
||||
Local setup:
|
||||
|
||||
```bash
|
||||
pip install "headroom-ai[proxy]"
|
||||
headroom proxy --port 8787
|
||||
```
|
||||
|
||||
Enable in Dashboard → Endpoint → Token Saver → Headroom. Default URL: `http://localhost:8787`.
|
||||
|
||||
Docker examples:
|
||||
|
||||
```bash
|
||||
# Headroom service in same Docker network
|
||||
http://headroom:8787
|
||||
|
||||
# Headroom running on host machine
|
||||
http://host.docker.internal:8787
|
||||
```
|
||||
|
||||
If Headroom is down or returns an error, 9Router fails open and sends the original request.
|
||||
|
||||
### 🎯 Smart 3-Tier Fallback
|
||||
|
||||
Create combos with automatic fallback:
|
||||
|
||||
Reference in New Issue
Block a user