Integration overview
| Integration | When to use |
|---|---|
| Python import | Any backend, scripts, notebooks |
| OpenAI-style wrapper | Chat APIs with messages[] |
| LangChain hook | Chains / agents with message history |
| Local HTTP server | Dev tools, non-Python clients |
| Browser demo | Judges, docs, no install |
Integration patterns
- Python
- OpenAI
- LangChain
- curl / HTTP
The core Track the sustainability impact of each compression call with the built-in metrics helper:
compress_for_turn() function accepts a list of context blocks (strings) and a user query, then returns compressed text and a stats object. This is the lowest-level entry point and works in any Python environment — backend services, Jupyter notebooks, or batch scripts.Policy selection quick reference
Use thepolicy argument to override the default SuperCompress learned policy with an explicit baseline, or omit it to let the library choose the best available option.
| Call | Policy used |
|---|---|
compress_context(text, q) | SuperCompress (or H2O fallback if no checkpoint) |
compress_context(..., policy=FIFO()) | Explicit FIFO baseline |
compare_policies(text, q) | All policies — returns dict keyed by policy name |