AI

pxpipe: How an Image Trick Lowers Claude Code Costs

4 min read
Photorealistic depiction: a developer feeds pages of text into a funnel from which a compact "PNG" image tile drops into a terminal bearing the Claude logo. Image generated with GPT Image 2
Photorealistic depiction: a developer feeds pages of text into a funnel from which a compact "PNG" image tile drops into a terminal bearing the Claude logo.

TL;DR Too Long; Didn’t read

The open-source tool pxpipe renders extensive text inputs for Claude Code – system prompts, tool documentation, older chat history – as PNG images because Anthropic charges flat rates based on pixel size rather than text content. According to developer Steven Chong, this reduces the overall bill by an average of 59 to 70 percent. The method is lossy: exact strings like hashes can be misrepresented from images without any detectable error. By default, pxpipe only supports Claude Fable 5 and GPT 5.6, as Opus and GPT-5.5 models read image content measurably worse. The basic idea is not new and builds on DeepSeek's OCR model for optical context compression.

Key takeaways

  • pxpipe is an open-source proxy that renders text context for Claude Code as PNG images to benefit from Anthropic's pixel-based rather than content-based image billing.
  • According to project claims, this reduces the overall bill by an average of 59 to 70 percent, in a documented example from $42.21 to $6.06 per session.
  • The method is lossy: exact strings like hashes can be misrepresented from rendered images, but plausibly so, without any error being displayed.
  • By default, pxpipe only supports Claude Fable 5 and GPT 5.6; Opus 4.7/4.8 and GPT 5.5 read image content measurably worse according to tests.
  • In SWE-bench tests, Claude Code with pxpipe solved nearly as many programming tasks with significantly smaller queries as without compression.
  • The basic idea is not new: DeepSeek has already released a model for architectural image compression of text with DeepSeek-OCR; pxpipe implements the same thought as a pure infrastructure trick on existing models.

An open-source tool called pxpipe exploits a peculiarity in Anthropic’s pricing model: images are billed by pixel size, not by their text content. Developer Steven Chong has built a local proxy for Claude Code that converts extensive text inputs into compact PNG images before they go to the Anthropic API – with the aim of significantly reducing the token bill.

How pxpipe works

According to the project description on GitHub, Anthropic charges a flat rate for a 1568-pixel-wide image, regardless of how much text it contains. For dense content like code, JSON, or terminal outputs, this allows for about 3.1 characters per image token, compared to around one character per text token in actual Claude Code traffic.

pxpipe acts as a local proxy between the Claude Code client and the Anthropic API. It intercepts requests to the /v1/messages endpoint and renders the extensive, repetitive parts of a request – system prompt, tool documentation, older chat history – as PNG pages before forwarding them. Current messages, recent conversation histories, and the model outputs themselves remain unaffected and are transmitted unchanged as text.

The savings in detail

According to the project, the total bill decreases on average by 59 to 70 percent, based on the actual production log of 13,709 requests. The lower value of 59 percent refers to the complete bill including the approximately 6,000 small requests that pxpipe leaves untouched; for the 7,756 actually compressed requests, costs decrease by 72 percent according to the repository. In a documented example with Claude Fable 5, session costs dropped from $42.21 to $6.06.

The method is not solely based on image size but follows a profitability threshold described in the repository: only content where converting to an image is actually worthwhile based on the measured characters-per-token values is compressed. Loosely written English prose, for example, becomes more expensive as an image rather than cheaper and thus remains as text.

Accuracy: Where there are issues

The method is explicitly lossy according to the project description. In a so-called needle-in-haystack test for reproducing exact 12-digit hexadecimal strings from rendered images, the Opus model achieved 0 out of 15 correct answers, while Fable 5 managed 13 out of 15. The documented failure mode is not a recognizable error but a “silent confabulation”: the model returns a plausible but incorrect value without indicating this. For information that must remain byte-accurate – IDs, hashes, secrets, exact numbers – the project therefore recommends keeping these as text.

By default, pxpipe only supports Claude Fable 5 and GPT 5.6. According to the evaluations documented in the repository, Opus 4.7 and 4.8 experience reading errors in about 7 percent of the rendered images; GPT 5.5 also performs worse with image content. Both models are therefore not automatically activated but can only be manually enabled via a configuration option. In benchmarks with new, previously unknown random numbers, Fable 5, on the other hand, achieves 100 percent accuracy in arithmetic tasks – both as text and as a rendered image.

Practical tests with SWE-bench

Beyond pure accuracy benchmarks, the project has also tested the impact on complete programming tasks. In a test run with ten tasks from the easier SWE-bench-Lite dataset, Claude Code solved 10 out of 10 tasks with and without pxpipe, with a reduction in request size of 65 percent. In 19 completed, more challenging pairs from SWE-bench Pro, 14 out of 19 tasks were solved with pxpipe compared to 15 out of 19 without compression, with a reduction in request size of 60 percent. The evaluations matched in 18 out of 19 cases; the only deviating case could be consistently reproduced according to the project through triple repetition and is classified as ordinary variation between individual agent runs, not as a result of image compression.

Not a completely new idea

The idea of passing text in compressed image form to AI models has a predecessor: DeepSeek has released a model called DeepSeek-OCR that compresses text documents via a 2D image representation. According to the associated technical paper, the model achieves a decoding accuracy of around 97 percent at a compression ratio of less than tenfold, while at a twentyfold ratio, it drops to about 60 percent.

The AI commentator Chubby (@kimmonismus) classified pxpipe on X accordingly: DeepSeek treated the problem as a model or architecture question, while pxpipe approached it as a pure infrastructure trick that exploits the fact that current models can already read images well enough. This makes the approach less elegant and more prone to loss, but still noteworthy.

Classification

pxpipe primarily highlights a gap in the current pricing model, not primarily a technical breakthrough: as long as image tokens are billed flatly by pixel size and not by informational content, this difference can be strategically exploited for dense, token-rich content like code. The project’s own benchmarks also openly document the limitations of the method – from the approximately 7 percent increased error rate in Opus models to the fundamental unsuitability for content that must remain byte-accurate. Whether the pricing structure of model providers changes in response to such tools remains to be seen.

Frequently asked questions

What is pxpipe?

pxpipe is a local proxy that renders extensive text inputs for Claude Code – such as system prompts, tool documentation, and older chat history – as PNG images before they are sent to the Anthropic API.

Why does converting to images save costs?

Anthropic charges images flat rates based on pixel size rather than text content. With dense content like code or JSON, more characters fit into an image token than into a text token, which according to the project allows for overall cost savings of 59 to 70 percent.

How accurate is the image compression?

The method is lossy. In a test for reproducing exact strings from images, Opus achieved 0 out of 15 correct answers, Fable 5 13 out of 15. The failure mode is a silent, unmarked misinterpretation rather than a detectable error.

Which models does pxpipe support?

By default, pxpipe supports Claude Fable 5 and GPT 5.6. Opus 4.7/4.8 and GPT 5.5 read rendered images measurably worse according to documented tests and are therefore only optionally switchable.

Is the idea of passing text as an image new?

No. DeepSeek has already released a model that compresses text documents via 2D image representation with DeepSeek-OCR. pxpipe differs in that it implements compression as a pure infrastructure trick on existing models rather than embedding it architecturally in the model itself.

#AI

← Back to the blog