pxpipe
A local proxy that cuts Claude Code token cost by rendering dense text context as PNG images before it reaches the model — teamchong reports ~59–70% lower input cost on real Anthropic traffic. It sits in the same “compress the context before the model sees it” corner as headroom, but by a completely different trick: instead of compressing text into smaller text, it re-routes text through the vision channel.
The mechanism — modality arbitrage
Image token cost is a function of pixel dimensions, not text density, so a densely-packed rendered
image carries far more characters per token than the same text as tokens — pxpipe cites ~3.1 chars per
image-token vs ~1 char per text-token. It intercepts API requests and renders the dense, stable
content (system prompts, tool documentation, older chat history, big file outputs) to images, repurposing
the vision path Claude already uses for screenshots. @napi-rs/canvas does the rendering (build-time
only); runs on Node and edge/Workers. TypeScript. eval/ ships SWE-bench, needle-in-haystack, and
gist-recall suites.
The catch — it’s lossy on exact strings
The approach silently degrades byte-exact content: hex IDs, hashes, and precise tokens in a dense render can be misread by the model’s OCR with no error raised. The repo’s own numbers show it getting worse on stronger models — 13/15 accuracy on Fable 5, 0/15 on Opus — so the mitigation is to keep recent conversation turns and byte-critical data as text, imaging only old/stable/dense context.
Why it matters here
- A second pole in the pre-model compression corner. headroom compresses text→smaller-text with content-typed compressors and a reversible cache (retrieve the original on demand). pxpipe does modality arbitrage — text→image to exploit token pricing, not to compress information — and is irreversibly lossy at the character level. Same corner, opposite reliability profile.
- A new lever for tokenmining. Beyond routing and context compaction, pxpipe adds “change the modality the tokens are counted in” — a pricing-arbitrage lever rather than an information-compression one. It’s the demand-side answer to the vendor metering the wrapper (like headroom), taken to its most literal: game how tokens are counted.
- A fidelity tension, flagged in synthesis. Where the spoke’s reliability thread pushes output-grounded verification and byte-exact correctness, pxpipe trades correctness for cost — and gets less safe as the underlying model improves. That inverse relationship (better model → worse OCR fidelity here) is the sharp, unusual claim worth watching.
Cross-spoke
The mechanism — image tokens priced by pixel area, and how a model OCRs rendered text — is the seam to llm-inference-wiki (tokenization / multimodal token accounting) and llm-providers-wiki (image-vs- text token pricing). Cross-linked; the subject here is the proxy tool, not the pricing table.
Tier
T1 — first-party repo, primary on itself. The 59–70% savings and the accuracy figures are the
project’s own eval/ results, not independently reproduced (weakness recorded). freshness: volatile
(pricing- and model-dependent).
Related
text-first-agent-design · headroom · tokenmining · anthropic-agent-sdk-billing-pause · agentic-coding-harness · anthropic · synthesis