headroom
Library and proxy that compresses logs, files and tool output so coding agents send fewer tokens to the model.
- Stars
- 80,801 stars
- Forks
- 6.3k forks
- Last push
- today
- Activity
- Active
# Install the CLI$ uv tool install --python 3.13 "headroom-ai[all]"# Run Claude Code through Headroom$ headroom wrap claudeCommands from the project's README. Run them after installing (see below).
Overview
Understand headroom in 60 seconds
- What it does
- Headroom compresses what an AI agent or app sends to a language model (tool outputs, logs, retrieved chunks, files and chat history) before it reaches the model. It runs on your machine as a Python or TypeScript library, a local proxy, or a wrapper around coding agents like Claude Code and Codex.
- The problem it solves
- Agents pay for every input token, and much of what they read is repetitive JSON, logs and file contents. Headroom shrinks that content locally and keeps the originals so the model can fetch the full text when it needs it.
- Why choose it
- Choose it to cut input tokens with no code changes for coding agents, or one function call in your own app. The README reports 21 to 57% fewer input tokens across four agent scenarios and little gain on plain prose.
- Who should use it
- Developers paying for LLM input tokens in their apps
- Claude Code, Codex, Cursor and Copilot users
- Teams building agents with LangChain, LiteLLM, Agno or Strands
- Anyone wanting local, private prompt compression
- Setup difficulty
You'll need:
- Python 3.13 with uv (recommended) or pip
- Node.js for the TypeScript SDK
- An existing LLM app or coding agent
How headroom works
Headroom works four ways: a compress() function you call in Python or TypeScript, a proxy you run on port 8787 with no code changes, a wrap command that launches a coding agent through the proxy, and an MCP server with compress, retrieve and stats tools.
Inside, a content router detects whether text is JSON, source code or prose and picks a compressor for each. A cache aligner flags content that would break a provider's prompt cache, and CCR keeps originals locally so the model can call headroom_retrieve for the full text. Compression runs on your machine; the README says no prompt or file content is sent anywhere to be compressed.
Extras include cross-agent memory shared by Claude, Codex, Gemini and Grok, headroom learn (which mines failed sessions and writes corrections to files like CLAUDE.local.md) and output token reduction. Headroom Enterprise is a separate commercial offering; this repository stays Apache-2.0.
Features
Key features
Library
compress(messages) in Python or TypeScript.
Proxy
Drop-in local proxy for any OpenAI-compatible client.
Agent wrap
One command for Claude Code, Codex, Cursor, Copilot, Aider and more.
Reversible
Originals cached locally and retrievable on demand.
MCP server
Compress, retrieve and stats tools for MCP clients.
Cross-agent memory
One shared memory store across agents.
Strengths
- Runs locally; content isn't sent out to be compressed
- No code changes needed for coding agents
- Measured savings published in the README
- Apache-2.0 licensed
Limitations
- Savings are small on plain prose
- headroom wrap's proxy only lives as long as the wrapped session
- Adds another moving part between your app and the provider
Practical use cases
Cheaper coding agent sessions
Wrap Claude Code so logs and tool output are compressed.
Lower API bills in an app
Call compress() before each chat completion.
Team-wide proxy
Run headroom deploy for a persistent local proxy.
Installation
Install headroom
Commands come from Headroom's README. AIRepoHub hasn't run them yet. View source
Prerequisites
- Python 3.13 and uv, or pip
Supported systems
- Windows
- macOS
- Linux
- 1
Install
Shelluv tool install --python 3.13 "headroom-ai[all]" - 2
Wrap a coding agent
Undo later with headroom unwrap.
Shellheadroom wrap claude - 3
Check it works
Shellheadroom doctor
- 1
Install
Shellpip install headroom-ai - 2
Compress messages before calling the model
Textfrom headroom import compressresult = compress(messages, model="gpt-4o")client.chat.completions.create(model="gpt-4o", messages=result.messages)
- 1
Install the SDK and the proxy
The npm SDK sends messages to the proxy.
Shellnpm install headroom-aipip install "headroom-ai[proxy]"headroom proxy --port 8787
Configuration and API keys
| Setting | What it's for |
|---|---|
HEADROOM_OFFLINEOptional | Set to 1 for a run with no network access. |
First run
- 1
Run the health check
Shellheadroom doctor - 2
Watch savings live (proxy must be running)
Shellheadroom dashboard
headroom's documentation doesn't include sample output, so we don't show any. Expect the results in your terminal.
Your first project
Compress messages in your own Python app
Cut input tokens before calling the OpenAI API.
Before you start
- Python
- pip install headroom-ai openai
- An OpenAI API key
- 1
Compress, call and report savings
Textfrom headroom import compressfrom openai import OpenAImessages = [{"role": "user", "content": "Analyze these results"}]result = compress(messages, model="gpt-4o")client = OpenAI()response = client.chat.completions.create(model="gpt-4o", messages=result.messages)print(f"Saved {result.tokens_saved} tokens ({result.compression_ratio:.0%})")
What to expect
The request goes through with compressed messages and the script prints how many tokens were saved. User messages are left alone unless you pass compress_user_messages=True.
Next steps
- Try headroom wrap claude for a coding agent
- Run headroom proxy for other languages
- Read the API reference at docs.headroomlabs.ai
Costs and requirements
What it costs to run
- License
- Apache-2.0. Free to use, modify and use commercially.Free
- Software
- Free; compression runs on your machine.Free
- Headroom Enterprise
- Separate commercial offering for teams.Paid
Troubleshooting
Common setup issues
Not sure routing works
Run headroom doctor to confirm requests go through Headroom.
The proxy stops when the agent exits
headroom wrap is session-scoped; use headroom deploy for a proxy that survives reboots.
Want to remove it from an agent
Run headroom unwrap followed by the tool name, for example headroom unwrap claude.
User messages aren't compressed
That is the default; pass compress_user_messages=True to include them.
Alternatives
Similar AI repositories
hermes-agent
NousResearch
Personal AI agent from Nous Research that learns and improves the more you use it.
ui-ux-pro-max-skill
nextlevelbuilder
AI agent skill that gives coding assistants design guidance for building polished user interfaces.
graphify
Graphify-Labs
Agent skill that turns a codebase and its docs into a searchable knowledge graph for Claude Code, Cursor, Codex and Gemini CLI.
spec-kit
github
GitHub toolkit for spec-driven development, where you write a specification first and let an AI coding agent build from it.