pxpipe
A local proxy that reduces Claude Code token costs by rendering bulky text context (system prompts, tool docs, history) as compact PNG images before sending requests.
At a Glance
Fully free and open-source under the MIT license. Run locally via npx or install as a library.
Engagement
Available On
Listed Jul 2026
About pxpipe
pxpipe is an open-source local proxy written in TypeScript that intercepts Claude Code API requests and rewrites dense text content — system prompts, tool documentation, and older conversation history — into compact PNG images before they leave your machine. The project was created by teamchong and published on GitHub under the MIT license, reaching 1,823 stars as of early July 2026.
What It Is
pxpipe exploits a fundamental asymmetry in how vision-capable language models bill tokens: an image's token cost is fixed by its pixel dimensions, not by how much text is packed inside it. Dense content like code, JSON, and tool output achieves roughly 3.1 characters per image-token versus approximately 1 character per text-token on real Claude Code traffic. The proxy sits between your terminal and the Anthropic API, compressing eligible input blocks into PNGs and forwarding the rewritten request — the model's response is never touched.
How the Compression Works
The pipeline wraps text at 1928-pixel-wide columns, packs roughly 92,000 characters per page, and encodes each page as a PNG. Three categories of input blocks are eligible, each behind a per-request profitability gate:
- Large
tool_resultbodies (file reads, command output, logs) above ~6k characters of token-dense content - Older collapsed conversation history — recent turns always stay as text
- The static system prompt and tool documentation slab
Everything else passes through byte-identical: your messages, recent turns, the model's output, sparse prose, and anything too small to win. Models outside the configured allowlist pass through entirely; the default scope is claude-fable-5 and gpt-5.6.
Benchmarks and Honest Tradeoffs
The README publishes reproducible benchmark results using novel random-number problems the model cannot have memorized. On claude-fable-5, novel arithmetic accuracy is 100/100 for both text and pxpipe arms at −38% tokens. Gist recall (decisions, values, paths, names, negations with distractors across 15k–45k character sessions) scores 98/98 on both arms. SWE-bench Lite pilot shows 10/10 on both arms at −65% request size.
The project is explicit about its lossy nature. Verbatim 12-character hex recall from dense renders scores 13/15 on Fable 5 and 0/15 on Opus 4.8 — and misses are silent confabulations, not errors. Byte-exact values (IDs, hashes, secrets) must stay as text; recent turns do. Opus 4.8 misreads roughly 7% of renders and is deliberately opt-in, never silently imaged.
Setup and Dashboard
Getting started takes about 30 seconds via npx pxpipe-proxy, then pointing Claude Code at the local proxy with ANTHROPIC_BASE_URL=http://127.0.0.1:47821. A built-in dashboard at that address shows tokens saved, every text-to-image conversion side by side, a kill switch, and live model chips. Events log to ~/.pxpipe/events.jsonl for per-request measurement against a free count_tokens counterfactual.
The library can also be used directly without the proxy, exposing renderTextToImages and transformAnthropicMessages functions for Node and edge/Workers environments. The @napi-rs/canvas dependency is build-time only, keeping the runtime pure JavaScript.
Update: v0.7.1
The latest release is v0.7.1, published on 2026-07-03. The repository was created in May 2026 and has been actively updated, with the last push on 2026-07-04. The roadmap lists ongoing hypotheses including sharper glyph rendering (paused mid-run), whether imaged bulk stretches effective context to roughly 2× real content in the same 1M window, and whether a smaller active context improves long-task accuracy — described as hypotheses that ship as numbers or get cut.
Community Discussions
Be the first to start a conversation about pxpipe
Share your experience with pxpipe, ask questions, or help others learn from your insights.
Pricing
Open Source
Fully free and open-source under the MIT license. Run locally via npx or install as a library.
- Local proxy via npx pxpipe-proxy
- Built-in dashboard
- Events log to ~/.pxpipe/events.jsonl
- Library API for Node and edge/Workers
- MIT licensed — free to use, modify, and distribute
Capabilities
Key Features
- Renders bulky text context as PNG images to reduce token costs
- Local proxy intercepting /v1/messages requests
- Compresses system prompts, tool docs, and older conversation history
- Per-request profitability gate — only images content where math wins
- Recent turns always stay as text for safety
- Built-in dashboard with tokens saved, side-by-side conversions, kill switch
- Events log to ~/.pxpipe/events.jsonl for per-request measurement
- Library API: renderTextToImages and transformAnthropicMessages
- Configurable model allowlist via PXPIPE_MODELS env var
- Prompt caching preserved — static prefix stays cache-friendly
- Pure-JS runtime (Node and edge/Workers)
- Responses stream normally — only request is compressed
