Skip to content
IFAI

Open source

A weird PNG hack slashes Claude token bills by 70%

Published Reach 48

Developer Steven Chong just open-sourced pxpipe, a local proxy that squeezes Claude Code context and system prompts into dense PNG images. Because Anthropic prices images by pixel dimensions rather than characters, users can cut token costs by up to 70%, though vision decoding adds slight latency and string loss.

A weird PNG hack slashes Claude token bills by 70%
Image: the-decoder.com

If you've been running AI coding agents through big codebases, you know the dread of watching your API bill climb with every iteration. Developers have tried trimming prompts and caching context, but Steven Chong found a wilder loophole: just send the AI a screenshot.

An open-source tool called pxpipe made waves by turning bulky Claude Code text into compact PNG images, slashing Claude Fable 5 token bills by up to 70%.

Squeezing 25,000 tokens down to 2,700

The trick relies on an awkward quirk in how AI providers price multimodal inputs.

Text costs roughly one token per character. But images are priced strictly by pixel dimensions, regardless of how much text is packed inside the frame. When you render monospace code or JSON into a dense image, you can fit around 3.1 characters into every single image token.

pxpipe acts as a local proxy sitting in front of Claude Code. It intercepts API requests and splits them into static and dynamic parts. Heavy, static boilerplate—like giant system prompts, tool schemas, and older chat history—gets rendered onto a dense PNG. Recent messages and new outputs still travel as normal text.

In one demo, around 48,000 characters of system prompts and documentation were crushed onto a single, tightly packed image page. As raw text, that payload would cost roughly 25,000 tokens. Handed over as an image, it cost about 2,700 tokens.

According to Chong, average token savings range between 59% and 70%. In one Claude Fable 5 coding session, costs plummeted from $42.21 to just $6.06.

The catch: speed and garbled strings

Turning code into pictures is clever, but it comes with real tradeoffs in accuracy and latency.

Image reading is inherently lossy. Exact, arbitrary strings like cryptographic hashes or long variable identifiers can easily get garbled when the vision model transcribes them. On top of that, running images through a vision encoder takes more compute time than scanning tokens directly, meaning slower round trips.

It also demands a remarkably capable vision model. pxpipe only enables Claude Fable 5 and GPT 5.6 by default. Chong notes that Fable 5 managed 100% accuracy on math benchmarks using randomized numbers the model couldn't have memorized.

Older engines struggle. Opus 4.7 and 4.8 misread around 7% of rendered text images, and GPT 5.5 showed noticeable degradation with image context. Both remain disabled by default in the repo.

The concept itself isn't completely foreign. Deepseek previously built an OCR document system that compresses text into images by up to 10x while maintaining 97% of the underlying information.

Why it matters

pxpipe is a brilliant piece of pricing arbitrage, born out of the raw economic pressure of running continuous agentic workflows.

For power users and independent developers running massive system prompts on Claude Fable 5, the math is undeniably attractive. Slashing an afternoon coding bill from $40 down to $6 is hard to ignore. But you shouldn't use it blindly: if your code depends on exact hashes, sensitive API keys, or tight latency loops, the vision transcription errors and slower generation times will bite you.

For AI providers, this is an awkward wake-up call. Anthropic and OpenAI set image pricing under the assumption that photos are mostly visual pixels, not wall-to-wall monospaced text exploiting compression ratios. If hacks like pxpipe become mainstream, we expect lab accountants to react quickly—either by hiking token prices on dense high-resolution images or by offering much steeper discounts on static text context.

Sources (1)

  1. [1]

Best of AI, daily