Skip to content
AIRepoHub

headroom

by headroomlabs-ai

Library and proxy that compresses logs, files and tool output so coding agents send fewer tokens to the model.

Coding AssistantsRAG & KnowledgePythonApache 2.0 license
Stars
80,801
stars
Forks
6.3k
forks
Last push
today
Activity
Active
headroom: quick start
# Install the CLI$ uv tool install --python 3.13 "headroom-ai[all]"# Run Claude Code through Headroom$ headroom wrap claude

Commands 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

Based on official documentation

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. 1

    Install

    Shell
    uv tool install --python 3.13 "headroom-ai[all]"
  2. 2

    Wrap a coding agent

    Undo later with headroom unwrap.

    Shell
    headroom wrap claude
  3. 3

    Check it works

    Shell
    headroom doctor
  1. 1

    Install

    Shell
    pip install headroom-ai
  2. 2

    Compress messages before calling the model

    Text
    from headroom import compressresult = compress(messages, model="gpt-4o")client.chat.completions.create(model="gpt-4o", messages=result.messages)
  1. 1

    Install the SDK and the proxy

    The npm SDK sends messages to the proxy.

    Shell
    npm install headroom-aipip install "headroom-ai[proxy]"headroom proxy --port 8787

Configuration and API keys

SettingWhat it's for
HEADROOM_OFFLINEOptionalSet to 1 for a run with no network access.

First run

  1. 1

    Run the health check

    Shell
    headroom doctor
  2. 2

    Watch savings live (proxy must be running)

    Shell
    headroom 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. 1

    Compress, call and report savings

    Text
    from 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.

Source: README.md

The proxy stops when the agent exits

headroom wrap is session-scoped; use headroom deploy for a proxy that survives reboots.

Source: README.md

Want to remove it from an agent

Run headroom unwrap followed by the tool name, for example headroom unwrap claude.

Source: README.md

User messages aren't compressed

That is the default; pass compress_user_messages=True to include them.

Source: README.md

Alternatives

Similar AI repositories