PX Pipe: Cut Coding Agent Token Costs by Turning Text Into Images
PX Pipe is a free open-source proxy that renders coding agent context as images to cut Claude Code and Codex bills, if your model can read it.

What is PX Pipe and how does it reduce token costs?
PX Pipe is an open-source, MIT-licensed proxy that sits between your coding agent and the model provider, rewriting bulky text in your request into rendered images before sending it on. The trick works because image tokens and text tokens are priced differently: a model bills image tokens by pixel size, not by how many characters are packed into the picture. On real Claude traffic, a text token holds roughly one character of dense code or JSON, while an image token can hold around 3.1 characters of the same content when rendered as a page of small, dense text. Pack more characters per token, and the bill drops, sometimes dramatically.
TL;DR
- PX Pipe is a local proxy, available via
npx px-pipe-proxy, that intercepts requests from coding agents like Claude Code, Codex, OpenCode, and Antigravity CLI and converts specific parts of the context into PNG images. - It only images three things: the large static system prompt and tool docs block, big tool outputs like file reads or command logs over roughly 6,000 characters, and older chat history, while your recent turns and your own messages always stay as plain text.
- Measured end-to-end savings on Claude Opus/Sonnet-era testing ranged from 59 to 70% lower bills, with one demo session dropping from about $42 to about $6 for the same task.
- Not every model can actually read the rendered text accurately: Gemini 3 Pro and Gemini Flash models read it almost perfectly, while Sonnet, Haiku, GPT-5 class models, Kimi, and DeepSeek variants are flagged by the project as unreliable or unsuitable for imaging.
- Weak readers don’t fail loudly when they misread an image; they confidently hallucinate plausible-looking text, which is the main risk to weigh against the savings.
- The tool preserves Anthropic’s prompt cache boundary, which matters because re-rendering images every turn would otherwise break caching and cost you more, not less.
- A dashboard and offline export mode let you inspect exactly what got imaged, toggle which models get the treatment, and even generate image bundles for tools that don’t support a proxy at all.
Prompt
Stop stitching scripts.Ship one system.
One spec produces the whole app, with security and compliance included.
How does PX Pipe actually work under the hood?
PX Pipe runs locally and starts a proxy (by default on port 47821) that also serves as a dashboard. You point your agent at it using a “warp” command rather than changing a base URL: something like px-pipe warp -- claude for Claude Code, px-pipe warp -- agi for Antigravity CLI, or px-pipe warp -- opencode for OpenCode. It also supports Codex. Because warp only redirects specific provider routes instead of rewriting the whole endpoint, things like OAuth logins and remote connectors inside these tools keep working normally.
On the request side, PX Pipe identifies the three categories of content worth imaging (system prompt and tool docs, large tool results, and older history), renders them as dense pages of small pixel text with a banner and line-break markers, and forwards the modified request to the provider. The response always streams back as ordinary text, so nothing changes in how the model replies to you.
For every request, the proxy also calls the provider’s free token-counting endpoint on the original, uncompressed body and logs that next to what you were actually billed. Both numbers land in an events file in your home directory, so the claimed savings aren’t just marketing copy. You can check them yourself, and the px-pipe stats command reads that file to print a report of compression, latency, and cache hit rates even when the proxy isn’t actively running.
Which models can actually read the images?
This is the part of the project worth paying close attention to before turning it on. Rendering text as pixels only saves money if the model can still extract the information correctly, and vision is not OCR. According to testing described in the project’s documentation, models were given log images containing 15 random hex IDs and asked to read them back exactly:
Gemini 3 Pro read all 15 correctly. Gemini Flash variants got 14. The original Claude model tested got 13. But newer Claude models performed worse: Opus scored only 3 out of 15, and Sonnet scored 2. Adding a couple of pixels of row spacing improved some Claude models back into the mid-teens, which is why PX Pipe adjusts render settings per model rather than using one fixed format.
Based on this, the project sorts models into three tiers. “Full readers” (Gemini Pro, Gemini Flash, and the original Claude 5-era model) can be trusted with imaged exact values. “Gist readers” (certain Opus and Claude 5.1/5.2 variants) understand the general content and handle arithmetic fine but shouldn’t be trusted with exact IDs or numbers pulled from an image. And a “do not image” list includes Haiku, Sonnet, GPT-5 class models, Kimi, and DeepSeek variants, meaning the project itself advises against using this technique with those models at all.
What happens when a weak reader misreads an image?
| Vendor | Tier | Risk | ApprovalNEW |
|---|---|---|---|
| Northwind Supply | Tier 1 | Low | Approved |
| Acme Logistics | Tier 2 | Medium | Approve |
| Helios Data | Tier 1 | High | Pending |
| Granite Freight | Tier 3 | Low | Approved |
| Pinecrest Labs | Tier 2 | Low | Approve |
It doesn’t throw an error. It guesses, and the guess looks confident and plausible even when wrong. The project’s own documentation describes a real case where a model recalled a person’s name from imaged chat history and got it wrong with full confidence. The failure mode isn’t garbled text, it’s quietly incorrect text that reads naturally.
A specific example involves font rendering: a zero and an eight differ by a single pixel in the font PX Pipe uses, so even a strong reader like Gemini can occasionally misread one as the other. To mitigate this, PX Pipe attaches a small text “factsheet” alongside the image containing the exact IDs and numbers, giving the model something to cross-check against instead of relying purely on pixel reading.
In coding sessions this risk is lower than it sounds, because agents typically re-read a file from disk before editing it rather than trusting memory. The bigger risk is in pure chat recall or pulling exact values out of old logs, where there’s no file to double-check against.
Is PX Pipe worth using in your coding workflow?
If you’re running Gemini 3 Pro or Gemini Flash, the case is strong: those models read the rendered pages close to perfectly, and the token savings are substantial. If you’re on an older Claude 5-class model, the same logic largely holds. If you’re on a newer Opus model, it can still save money in a typical coding session where the agent re-verifies file contents before acting, but you should avoid relying on it for work where exact strings or numbers matter. If you’re on Sonnet, Haiku, or most current open-weight models, the project’s own documentation says not to bother yet.
What stands out is the transparency. Most token-saving tools only show the savings on the piece they touched. PX Pipe shows the full bill, including the parts it never compresses, and publishes a table of which models fail to read its output reliably. The tradeoffs are real: there’s added latency from encoding images on each request, and the reliability tiers shift as providers release new model versions, meaning a model that reads well today could get worse (as happened with one Claude model between versions). For teams already using Gemini-family models for coding agents, it’s a low-risk way to cut costs. For everyone else, it’s worth watching rather than adopting immediately.
Frequently Asked Questions
Does PX Pipe change what the model outputs?
No. It only modifies the request sent to the provider by converting parts of the input context into images. The model’s response always streams back as normal text, unchanged.
Will using PX Pipe break prompt caching?
No, on Anthropic’s API it preserves the prompt cache boundary. This is deliberate: if the rendered images changed every turn, caching would break and costs could actually increase instead of decrease.
Can I use PX Pipe without running a proxy?
Yes. It includes an offline export mode (px-pipe-proxy export) that converts a folder of files, piped text, or a git diff into image pages, a factsheet, and a prompt file you can upload manually to tools that accept images, such as certain IDE-integrated assistants.
Which models should I avoid imaging context for?
Everyone else built a construction worker.
We built the contractor.
One file at a time.
UI, API, database, deploy.
Based on the project’s own testing, models identified as unreliable readers include certain Claude Sonnet and Haiku versions, GPT-5 class models, Kimi, and some DeepSeek variants. The project explicitly recommends not imaging context for these.
How are the reported savings verified?
PX Pipe sends the original, uncompressed request to the provider’s free token-counting endpoint for every call and logs that figure next to the actual billed amount in a local events file, letting users audit the claimed savings against their own usage.



