Skip to content

feat: add optional Headroom token saver#1899

Closed
CarmeloCampos wants to merge 1 commit into
decolua:masterfrom
CarmeloCampos:feat/headroom-token-saver
Closed

feat: add optional Headroom token saver#1899
CarmeloCampos wants to merge 1 commit into
decolua:masterfrom
CarmeloCampos:feat/headroom-token-saver

Conversation

@CarmeloCampos

Copy link
Copy Markdown

Summary

  • Adds optional Headroom compression via an external /v1/compress proxy before provider dispatch
  • Adds dashboard and CLI toggles plus configurable Headroom proxy URL
  • Documents local and Docker setup while keeping Headroom unbundled

Why

Closes #1871.

This lets users run:

Client -> 9Router -> Headroom /v1/compress -> 9Router -> provider

9Router keeps routing, auth, fallback, usage logging, and provider translation. Headroom only handles context compression.

Benefits

  • Optional extra token savings on top of RTK
  • No new runtime dependency or bundled Python process
  • Docker-friendly via configurable URL, e.g. http://headroom:8787 or http://host.docker.internal:8787
  • Fail-open behavior: if Headroom is down or errors, the original request is sent unchanged

Testing

  • NODE_PATH=tests/node_modules tests/node_modules/.bin/vitest run --config tests/vitest.config.js tests/unit/headroom.test.js --reporter=verbose -> 6 passed
  • npm run build -> TypeScript completed

@GabrielCastroV

Copy link
Copy Markdown

Looks pretty good actually 👀

bloodf pushed a commit to bloodf/9router that referenced this pull request Jun 19, 2026
@decolua

decolua commented Jun 20, 2026

Copy link
Copy Markdown
Owner

Thanks a lot for this contribution, @CarmeloCampos! 🙏

The optional Headroom token saver integration is a great addition. We've merged it locally and built on top of it with:

  • Managed start/stop of the local Headroom proxy directly from the dashboard
  • CLI install + Python (>=3.10) detection and proxy /health probing
  • One-click Start/Stop UI in Token Saver, no manual config needed
  • Claude <-> OpenAI shape conversion for /v1/compress via the 9Router translators

Closing this PR as the work has been integrated. Really appreciate the original implementation that made it easy to extend. 🚀

@decolua decolua closed this Jun 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Feature Request: Integrate Headroom compression layer (60-95% token reduction)

3 participants