Headroom
Context optimization layer for LLM applications. Compress tool outputs, logs, files, and RAG chunks before they reach the model. Same answers, 60โ95% fewer tokens. Library, proxy, and MCP server. Apache 2.0, local-first.
Headroom is shipped as a Python package (headroom-ai), a TypeScript package (headroom-ai), an OpenAI + Anthropic-compatible HTTP proxy (headroom proxy), and an MCP server (headroom_compress, headroom_retrieve, headroom_stats tools). All four modes use the same compression pipeline: per-content-type compressors (JSON, code, logs, diffs, text) feed into a Compress-Cache-Retrieve (CCR) store so compression stays reversible โ the LLM can ask for the original whenever it wants.
The canonical, always-current documentation index lives at the docs site below. If you can fetch one URL, fetch that one; the entries here are a hand-curated subset.
Canonical docs (start here)
- Live llms.txt (full doc index): Auto-generated index of every doc page with descriptions.
- Live llms-full.txt (every doc page concatenated): One Markdown blob containing every doc page. Use when you can spend the tokens for full context.
- Docs site: Human-browsable docs with search.
- GitHub repo: Source, issues, releases.
- PyPI package: Python install.
- npm package: TypeScript install.
Install (copy-paste-runnable)
- Python:
pip install headroom-ai(add[all]for every optional extra) - TypeScript / Node:
npm install headroom-ai(orpnpm add headroom-ai,bun add headroom-ai) - Docker:
docker run -p 8787:8787 ghcr.io/headroomlabs-ai/headroom:latest - Run the proxy:
headroom proxy --port 8787then point any client athttp://127.0.0.1:8787 - Wrap an agent in one command:
headroom wrap claude(also:codex,copilot,cursor,aider,opencode,cline,continue,goose,openhands,openclaw,vibe,omp)
Entry points
- Quickstart: 5-minute end-to-end (install โ compress โ call the model).
- Installation: All install paths, extras, Docker tags, env vars.
- Proxy server: Run as a local HTTP proxy in front of OpenAI / Anthropic / Gemini.
- MCP server:
headroom_compress,headroom_retrieve,headroom_statsfor Claude Code / Cursor / any MCP host. - API reference: Python + TypeScript
compress()API.
How it works
- How compression works: Three-stage pipeline + automatic content routing.
- SmartCrusher: Statistical JSON / array compression (70โ90% on tool outputs).
- Code compression: AST-aware via tree-sitter (preserves imports, signatures, types).
- Text & log compression: Search results, build logs, diffs.
- CCR (reversible): Compress-Cache-Retrieve โ originals never deleted; LLM retrieves on demand.
SDK / framework integrations
- Anthropic SDK:
withHeadroom(anthropic)wrapper. - OpenAI SDK:
withHeadroom(openai)wrapper. - Vercel AI SDK: Middleware +
withHeadroom(). - LangChain: Chat models, memory, retrievers, agents.
- Agno: Model wrapping + observability hooks.
- Strands: Model wrapping + hook-based tool output compression.
- LiteLLM: Single callback; works with all 100+ LiteLLM providers.
Memory & cross-agent state
- Persistent memory: Per-project SQLite + HNSW vector store. No cross-project bleed (GH #462).
- SharedContext: Compressed inter-agent context handoffs.
- Failure learning: Offline analysis writes corrections to
CLAUDE.local.md(default, gitignored) orCLAUDE.md(shared) /AGENTS.md/GEMINI.md.
Operations
- Configuration: Env vars, config file, per-call overrides.
- Benchmarks: Token-savings numbers across content types.
- Troubleshooting: Common failure modes and fixes.
- Limitations: What Headroom won't do well today.
Licensing
Apache 2.0. Use commercially, modify, redistribute. Data stays on the user's machine when running the library, proxy, or MCP server locally. Anonymous telemetry is off by default (opt-in); enable with HEADROOM_TELEMETRY=on or headroom proxy --telemetry.