pxpipe: Reducing Claude Fable 5 Token Costs by Converting Context to Images
Overview
pxpipe is a local proxy designed to reduce the input token costs of LLM requests by rendering bulky text context—such as system prompts, tool documentation, and older chat history—into compact PNG images. By exploiting the difference between fixed-cost image tokens and variable-cost text tokens, pxpipe can reduce end-to-end bills by approximately 59% to 70% for token-dense workloads.
The Mechanism: Text-to-Image Token Arbitrage
pxpipe operates on the principle that an image's token cost is determined by its pixel dimensions rather than the amount of text it contains. For dense content like code or JSON, pxpipe achieves a density of approximately 3.1 characters per image-token, compared to roughly 1 character per text-token.
How the Transformation Works
- Interception: The proxy intercepts
/v1/messagesrequests. - Filtering: A profitability gate determines if the content is "token-dense" (e.g., code, JSON, hashes). Sparse English prose is left as text because it is more token-efficient.
- Rendering: Eligible text is wrapped at 1928px-wide columns and packed into PNG pages (up to ~92,000 characters per page).
- Injection: The images are spliced back into the request in a cache-friendly manner, ensuring that static prefixes are preserved so that prompt caching continues to function.
Economic Efficiency
A 1928×1928 image costs approximately 4,761 vision tokens but can hold up to 92,000 characters. In contrast, the same amount of text would typically require significantly more tokens. The system is specifically calibrated for Claude Code transcripts, where the observed density is 1.91 characters per token.
Performance and Benchmarks
Model Compatibility
pxpipe is primarily tuned for Claude Fable 5, which achieved a 100/100 score on clean evaluations for reading these renders. While it supports other models, Claude Opus 4.8 is disabled by default because it misread approximately 7% of renders.
Task Accuracy
- Novel Arithmetic: Fable 5 maintained 100% accuracy compared to the text baseline, with a 38% reduction in tokens.
- SWE-bench Lite: In a pilot of 10 instances, pxpipe resolved 10/10 tasks, matching the text baseline while reducing request size by 65%.
- SWE-bench Pro: In a harder, long-horizon set of 19 pairs, pxpipe resolved 14/19 tasks compared to 15/19 for the text baseline. The single discrepancy was attributed to agentic variance rather than compression loss.
Verbatim Recall Limitations
pxpipe is a lossy system. It is designed for "gist" recall rather than byte-exact storage.
- Opus: 0/15 success rate for recalling 12-character hex strings from dense renders.
- Fable 5: 13/15 success rate for the same task.
Failure modes typically manifest as "silent confabulation," where the model provides a plausible but incorrect value. To mitigate this, pxpipe allows users to pin specific blocks as text via options.keepSharp() or route exact-recall tasks to non-Fable models (e.g., Claude Sonnet 4.6).
Deployment and Usage
Users can run pxpipe as a proxy to point Claude Code at a local endpoint:
npx pxpipe-proxy
ANTHROPIC_BASE_URL=http://localhost:47821 claude
Alternatively, it can be used as a library to render text to PNGs or transform Anthropic messages directly using renderTextToPngs and transformAnthropicMessages.
Community Insights and Critiques
Discussion among technical users highlights several concerns regarding the sustainability and nature of this approach:
"This seems like a pricing hack that burns resources, that when the loophole gets closed the price of OCR will have to rise?"
Some users suggest that this is a loophole in token accounting rather than a fundamental efficiency gain, noting that if the backend performs its own OCR to process the image, the resource cost remains the same while the billing is bypassed.
Other critics argue that the technique promotes waste by exploiting a pricing failure:
"It works, and it's clever, but it's clearly a workaround for a pricing failure... this just exploits and promotes waste."
Conversely, some developers note that similar techniques of using images for context compactification have been seen in other tools like OMP.sh (built on the Pi coding agent) and mentioned in DeepSeek whitepapers.
Sources
Related
- Project
- Dispatch
- Dispatch
- Dispatch
- Dispatch