pxpipe: Cut Claude Code Token Usage 60% by Rendering Context as Images

✍️ OpenClawRadar📅 Published: July 4, 2026🔗 Source
pxpipe: Cut Claude Code Token Usage 60% by Rendering Context as Images
Ad

pxpipe is a local proxy that exploits a pricing gap: AI models charge for images by pixel dimensions, not by embedded text density. For bulky context like system prompts, tool docs, and history, this means ~3.1 characters per image token vs ~1 char per text token on real Claude Code traffic. The result is a ~59–70% cost cut (list prices) and a ~72–74% cut on compressed requests, with the primary metric being input-token reduction — e.g., ~25k text tokens rendered as ~2.7k image tokens.

How it Works

pxpipe runs as a local proxy intercepting requests from Claude Code/Gateway. It rewrites the bulky parts (system prompt, tool documentation, older history) into compact PNG images before the request leaves your machine. The proxy also includes an OCR instruction banner co-rendered on top so the model can read the text reliably. Fable 5 achieves 100/100 read accuracy on a clean eval. Opus 4.8 struggles with dense image content (exact values should remain text).

Getting Started

npx pxpipe-proxy
# proxy on 127.0.0.1:47821
ANTHROPIC_BASE_URL=http://localhost:47821 claude

Open http://127.0.0.1:47821/ for a live dashboard showing tokens saved, per-session stats, and every text→image conversion side by side.

Ad

Key Results

  • Token reduction: Dense content compresses ~10x (25k text → 2.7k image tokens)
  • Cost savings: 59–70% lower bill on typical Claude Code traffic, 72–74% on compressed requests
  • Accuracy: Fable 5 model reads images at 100/100 on clean eval; Opus 4.8 is lossy for exact values
  • Demo comparison: Session totals: plain $42.21 (context 96% full) vs pxpipe $6.06 (context 7.4% full)

Limitations

Spare or small requests won't benefit. Opus 4.8 cannot reliably read exact values from images (e.g., phrase counts). Single-reply format compliance has minor rough edges (one follow-up nudges may be needed).

Who It's For

Developers using Claude Code with large system prompts, extensive tool docs, or long conversation histories — especially in Fable 5 environments.

📖 Read the full source: HN AI Agents

Ad

👀 See Also