pxpipe: Cut Claude Code Token Costs by 70% by Hiding Text in PNGs
pxpipe: Cut Claude Code Token Costs by 70% by Hiding Text in PNGs
TL;DR: pxpipe is a free, open-source local proxy (by developer Steven Chong / @teamchong) that sits between your software and Claude. It intercepts requests and renders bulky, static parts of your context — system prompts, tool documentation, older chat history — as compact PNG images before they leave your machine. Recent messages and model outputs pass through as normal text. The result? A 59–70% reduction in end-to-end token costs on Claude Fable 5, with one demo session dropping from $42.21 to $6.06. It has 3,800+ GitHub stars and is MIT-licensed.
The Trick: AI Pricing Has a Blind Spot
pxpipe works because of a quirk in how Anthropic prices API usage. Text costs roughly 1 token per character. But images cost a fixed number of tokens based on pixel dimensions — regardless of how much text is rendered inside them.
Here's the math that makes it work:
| Format | Token Cost | Density |
|---|---|---|
| Plain text | ~1 token per character | ~1 char/token |
| Text rendered as PNG | Fixed by pixel size | ~3.1 chars/image-token |
That 3.1x compression ratio is the difference between a $42 session and a $6 session.
Dense content — code, JSON, tool output, system prompts — benefits most. Sparse prose (around 3.5 chars per token in natural language) doesn't trigger the profitability gate, so pxpipe only images where the math wins.
How pxpipe Actually Works
pxpipe runs as a local proxy on your machine. You start it with a single command, then point Claude Code at it:
npx pxpipe-proxy
ANTHROPIC_BASE_URL=http://127.0.0.1:47821 claude
That's it. From there, pxpipe intercepts every request to Claude and:
- Identifies bulky static content — system prompts, tool documentation, and older chat history that doesn't need byte-exact fidelity
- Renders it as a dense PNG page — the same vision channel that Anthropic's computer use feature already relies on for screenshots
- Sends the image instead of raw text — recent messages and model outputs pass through as normal text
- Streams responses normally — pxpipe only compresses the request, never the model's output
A real-world example: ~48,000 characters of system prompt and tool documentation gets squeezed onto a single densely packed PNG page. As text, that costs about 25,000 tokens. As an image, it's roughly 2,700 tokens — a 9x reduction on that specific chunk.
A live dashboard runs at http://127.0.0.1:47821/ showing tokens saved, side-by-side text/image comparisons, a kill switch, and live model chips.
The Numbers: Benchmarks That Hold Up
The developer ran rigorous, reproducible benchmarks using novel random-number problems the model cannot have memorized — avoiding the trap of testing on training data where memorized answers could survive misreads.
| Benchmark | Model | N | Text Accuracy | pxpipe (Image) Accuracy |
|---|---|---|---|---|
| Novel arithmetic | Fable 5 | 100 | 100% | 100% |
| Novel arithmetic | Opus 4.8 | 100 | 100% | 93% |
| Gist recall A/B (decisions, values, paths) | Fable 5 | 98/arm | 98/98 | 98/98 |
| State tracking (value mutated 3x) | Fable 5 | 18/arm | 18/18 | 18/18 |
| Confabulation on never-stated facts (lower=better) | Fable 5 | 16/arm | 0/16 | 0/16 |
| Verbatim 12-char hex recall (dense render) | Fable 5 | 15 | 15/15 | 13/15 |
| Verbatim 12-char hex recall (dense render) | Opus | 15 | 15/15 | 0/15 |
| SWE-bench Lite pilot | Fable 5 | 10/10 | 10/10 | 10/10 |
| SWE-bench Pro | Fable 5 | 19 | 15/19 | 14/19 (verdicts agree 18/19) |
Fable 5 hits 100% accuracy on novel arithmetic problems — the hardest test because the model can't cheat with memorized answers. The gist recall and state tracking benchmarks also score perfectly on both arms.
The SWE-bench results are particularly telling: at 65% of the request size (meaning pxpipe sent 35% fewer tokens), the Lite pilot scored 10/10 on both arms. The Pro benchmark showed a single split that re-resolved on replication run-to-run variance, not compression artifacts.
The Honest Truth: Where pxpipe Falls Short
The developer is refreshingly transparent about the limitations:
1. It's Lossy
Exact 12-character hex strings in dense imaged content: 13/15 on Fable 5, 0/15 on Opus. And the misses are silent confabulations — the model doesn't say "I can't read that," it makes something up. Byte-exact values (IDs, hashes, secrets) must stay in text. Recent turns do, but a dedicated verbatim-risk guard is not built yet.
Escape hatch: Subagents on non-allowlisted models pass through as text. Route byte-exact work there with CLAUDE_CODE_SUBAGENT_MODEL=claude-sonnet-4-6 or model: sonnet in agent frontmatter.
2. Slower Processing
The model has to run rendered images through a vision encoder instead of reading text directly. This adds latency — the tradeoff for the cost savings.
3. Model Limitations
| Model | Default? | Performance |
|---|---|---|
| Claude Fable 5 | Yes (default) | 100% accuracy across benchmarks |
| GPT 5.6 | Yes (default) | Full support |
| Opus 4.7 / 4.8 | Opt-in only | Misreads ~7% of renders |
| GPT 5.5 | Opt-in only | Degrades on imaged context |
4. Workload-Dependent
pxpipe wins on token-dense content (~1 char/token) but would lose money on sparse prose (~3.5 chars/token). A profitability gate (calibrated on N=391 production rows) images only where the math wins.
Why This Won't Last Forever
This is the part that gives pxpipe its urgency. The trick works because of a pricing arbitrage — Anthropic prices images by pixel dimensions, not content density. If this approach catches on at scale, AI companies will almost certainly respond by raising image processing prices or changing how vision tokens are billed.
The developer acknowledges this directly. pxpipe is a clever exploit of a pricing model that wasn't designed for this use case. It works now, but there's no guarantee it will work at the same margins a year from now.
For developers and teams running heavy Claude Code workloads — especially those with large system prompts, extensive tool documentation, or long agent sessions — the savings are real and immediate. A single environment variable change can cut your bill by more than half.
How to Get Started (30 Seconds)
# Start the proxy
npx pxpipe-proxy
# Point Claude Code at it
ANTHROPIC_BASE_URL=http://127.0.0.1:47821 claude
The dashboard at http://127.0.0.1:47821/ shows real-time token savings, side-by-side comparisons of text vs. image renders, and a kill switch if something goes wrong.
GitHub: github.com/teamchong/pxpipe (3.8k stars, MIT license)
The Bottom Line
pxpipe is one of the most clever cost-hacking tools to emerge in the AI coding space. It exploits a genuine pricing blind spot in Anthropic's API to deliver real, measurable savings — 59-70% on typical Claude Code workloads — with surprisingly minimal accuracy degradation on the models it supports.
It's not a magic bullet. It's lossy, it's slower, and it won't work forever. But for anyone running Claude Code at scale today, the 30-second setup cost is trivial compared to the potential savings.
If you're spending serious money on Claude Code tokens, pxpipe is worth a try before the pricing loophole closes.
Looking for other free tools to optimize your AI workflow? Check out Voicebox for local AI voiceovers and Claude on FreeAlternatives.net.
Meta Title: pxpipe: Cut Claude Code Token Costs by 70% by Hiding Text in PNGs
Meta Description: pxpipe is a free open-source proxy that converts Claude Code text context into PNG images, slashing Fable 5 token costs by 59-70%. Local, lossy, clever.