Overview
pxpipe is a proxy you run on your own machine that sits between a coding agent and its model provider and rewrites the bulky parts of each request into compact PNG pages. The idea rests on how vision models are billed: an image's token cost is fixed by its pixel dimensions, not by how much text is drawn inside it, so dense content such as code, JSON and tool output packs far more characters per token as an image than as text.
In practice the system prompt, tool definitions and older conversation turns are the parts that get imaged, while recent turns stay as text. Only the request is compressed — responses stream back normally, untouched. A dashboard on the proxy port shows tokens saved, every text-to-image conversion side by side, live model chips and a kill switch, and each request is measured against a free count_tokens counterfactual logged to ~/.pxpipe/events.jsonl.
The project is unusually direct about its limits. Imaging is lossy: byte-exact values such as IDs, hashes and secrets can be silently confabulated, so they must stay in text, and a profitability gate calibrated on production traffic only images content where the token math actually wins — sparse prose costs more as an image than as text. Model support is an explicit allowlist; anything outside it passes through byte-identical.
What it does
- Local proxy for the Anthropic Messages API that images the system prompt, tool docs and older history while recent turns stay text
- Request-only compression — model responses stream back unchanged
- Dashboard on the proxy port with per-request savings, side-by-side conversions, model chips and a kill switch
- Per-request measurement against a count_tokens counterfactual, logged to ~/.pxpipe/events.jsonl
- A profitability gate that skips imaging on sparse prose, where rendering would cost more tokens than it saves
- Offline export mode that renders files, stdin or a git diff to PNG pages plus a factsheet, with no proxy involved
Getting started
The proxy runs from npx with no install. Point your agent's base URL at it, or let pxpipe wrap the command for you.
Start the proxy and point Claude Code at it
The proxy listens on 127.0.0.1:47821; the dashboard is served at the same address.
npx pxpipe-proxy
ANTHROPIC_BASE_URL=http://127.0.0.1:47821 claudeOr wrap the command instead
pxpipe warp runs the agent without setting ANTHROPIC_BASE_URL, so first-party gates and connectors keep working. Agents that reach their provider over a different base URL need an explicit route rule.
pxpipe warp -- claude
pxpipe warp --route '127.0.0.1:9090/v1/*=http://127.0.0.1:47821' -- codexChoose which models get imaged
PXPIPE_MODELS is an allowlist; models outside it pass through byte-identical, and PXPIPE_MODELS=off disables imaging entirely. The same chips are toggleable from the dashboard.
PXPIPE_MODELS=off npx pxpipe-proxyExport pages without running the proxy
Each run writes a fresh output folder containing page-*.png, factsheet.txt, manifest.json and prompt.txt, which you can upload to any image-capable client.
npx pxpipe-proxy export src/
cat prompt.txt | npx pxpipe-proxy export --stdin
npx pxpipe-proxy export --gitCommands and code are distilled from the project's own documentation — always check the official repo for the latest.
When to use it
- Cut the input-token bill of a long-running coding-agent session where the same system prompt and tool docs are re-sent on every turn
- Fit more of a large codebase into a fixed context window by trading text tokens for image tokens on the dense parts
- Measure what imaging would actually save on your own traffic before committing to it, using the logged counterfactual counts
- Render a directory or a git diff to PNG pages for an image-upload client when you cannot run a proxy at all
How pxpipe compares
pxpipe alongside other open-source context compression & token budgets tools AI/TLDR tracks, ranked by GitHub stars.
| Tool | Stars | What it does |
|---|---|---|
| RTK | ★ 80.9k | A single-binary Rust CLI proxy that filters, groups, truncates and dedupes the output of 100+ dev commands before a coding agent reads it, cutting token use by 60–90%. |
| Headroom | ★ 72.9k | Local context-compression layer that shrinks tool outputs, logs, files and RAG chunks before they reach the model, usable as a library, a drop-in proxy or an MCP server. |
| TOON | ★ 25.4k | Token-Oriented Object Notation: a lossless, compact encoding of the JSON data model that declares row counts and field lists so tabular data costs fewer prompt tokens. |
| Context Mode | ★ 23.4k | An MCP server that keeps raw tool output out of the context window by sandboxing it, and indexes session events into SQLite FTS5 so an agent survives compaction. |
| pxpipe | ★ 7.4k | A local proxy that sends bulky context to the model as images |