# pxpipe

> Local proxy that renders Claude Code's bulky context as images to cut input tokens

- Repository: https://github.com/teamchong/pxpipe
- Category: Token & cost savings
- Stars: 7,549 · Forks: 658 · Language: TypeScript · License: MIT
- Experience: Some experience
- Page: https://ir.adyog.com/repos/teamchong/pxpipe/

Coding agents like Claude Code re-send a lot of text on every request: the system prompt, tool documentation and old history. An image costs tokens by its pixel size, not by how much text it holds, so dense text packed into a picture can cost far less.

pxpipe runs on your machine between the agent and the API. It renders the bulky, older parts of each request into PNG pages, adds a short factsheet of precision-critical tokens, and keeps recent turns as text. Only the request changes; the model's streamed output is untouched. A dashboard shows tokens saved and each conversion side by side.

The README is open about the trade-offs. Reading images is lossy: exact hex strings are sometimes silently misread, depending on the model. It pays off on token-dense content like code and JSON and loses on sparse prose, so a profitability gate decides what to image. It reports roughly 60 to 70 percent lower bills on Claude Code traffic, checked per request against a count_tokens baseline.

## What it does

- **Local proxy for Claude Code**: Start it with npx and point ANTHROPIC_BASE_URL at it. Requests are rewritten on your machine before they leave.
- **Warp mode**: `pxpipe warp -- claude` gives the same effect without setting a base URL. The README says this keeps /remote-control and claude.ai connectors working, and it also lists cursor-agent and codex.
- **Dashboard and savings log**: A local page shows tokens saved, side-by-side text and image conversions, a kill switch and model toggles. Per-request counts are written to ~/.pxpipe/events.jsonl.
- **Offline export**: Render files, stdin or git diffs to PNG pages, a factsheet and a prompt without running the proxy. You can upload them to image-capable clients such as Cursor.
- **Per-model profiles and benchmarks**: Different render settings for Claude, Gemini, Sol and Grok, with published scores for arithmetic, gist recall and exact-hex recall. Several models are opt-in.

## What you could build

- Run Claude Code through the proxy to lower input token spend on long sessions.
- Fit more history into a context window before needing to compact.
- Export a source folder or git diff as PNG pages to paste into an image-upload client.
- Compare text and image versions of your own requests in the dashboard to check the savings.
- Wrap codex or cursor-agent with warp and a route rule to test imaging on other agents.

## Who it's for

Heavy Claude Code users who are comfortable with a local proxy and know that exact IDs, hashes and secrets should stay as text.

## Get started

Start the proxy with npx, then launch Claude Code with ANTHROPIC_BASE_URL pointing at it, or use pxpipe warp instead. Open http://127.0.0.1:47821/ to watch the savings.

```
npx pxpipe-proxy
```
```
ANTHROPIC_BASE_URL=http://127.0.0.1:47821 claude
```
```
pxpipe warp -- claude
```

Tags: claude-code, tokens, proxy, context, cost
