
headroom
Compress LLM context before it reaches the model
Replaces The Token Company, Kong Ai Gateway
Who it's for
Great for developers using AI coding agents who want to save on token costs.
Skip if you only use a single provider's native compaction.
Ideal for teams that work across various AI agents needing shared memory.
Skip if you work in a sandboxed environment where local processes can't run.
The problem
The project helps solve the problem of high token usage in LLM applications by compressing inputs without losing essential information.
How it works
Compresses data aggressively while retaining originals for retrieval.
Automatically detects and routes content types to the best compressor.
Enhances cache hits by stabilizing prefixes, leading to cost savings.
Reduces token usage by 40-90% through intelligent image processing.
Maintains memory across sessions using SQLite and HNSW backends.
Learns from past failures to improve future performance.
Features
- Lossless Compression
- Smart Content Detection
- Cache Optimization
- Image Compression
- Persistent Memory
- Failure Learning
How to install
Install the Python package with all extras, or add the Node package for TypeScript apps: pip install "headroom-ai[all]" npm install headroom-ai
Recommended for this setup
Strengths
- High Token Savings: Achieves 60-95% reduction in token usage while maintaining accuracy.
- Seamless Integration: Works with various frameworks and requires no code changes.
- Reversible Compression: Allows retrieval of original data after compression.
- Multi-Agent Support: Facilitates shared memory across different AI agents.
Trade-offs
- Not for Single Provider Use: Less beneficial for users relying solely on one provider's native compaction.
- Local Process Requirement: Requires local processes to run, which may not suit all environments.
Tech stack
FAQ
Headroom can compress tool outputs, database results, file reads, RAG results, and more.
It uses lossless compression techniques that retain original data for retrieval.
Yes, Headroom integrates seamlessly with various frameworks and requires minimal changes.