logo
Kurashizu Blogwhere ideas flow
  • Home
  • News
  • Blog
  • About
  • Home
  • News
  • Blog
  • About

© 2026 Kurashizu. All rights reserved.

Admin·New Post·Service Status
Powered by Cloudflare·02.11.26
← Back to news

60% Fable cost cut by converting code to images and having the model OCR it

Original article
github.com|42 points|14 comments|by dimitropoulos|Jul 3, 2026

Reducing Fable Costs by 60%: Converting Code to Images for OCR

The pxpipe project aims to drastically lower the input token overhead for Claude Code by transforming voluminous context—such as system prompts, tool documentation, and conversation history—into images.

💡 The Core Concept

The fundamental insight is that image token costs are determined by pixel dimensions, regardless of how much text is contained within the image. For dense data like JSON or source code, this creates a massive efficiency gap.

Token Efficiency Comparison

Content TypeText Token EfficiencyImage Token Efficiency
Dense Content≈1\approx 1≈1 char / token≈3.1\approx 3.1≈3.1 chars / token
Cost BasisPer character/tokenPer pixel area (fixed)

pxpipe acts as a local proxy. It intercepts your request and rewrites the "bulky" sections into compact PNGs before they are sent to the model.

📉 Measured Impact

While savings vary by workload, the reduction in input tokens is significant and durable.

  • Token Reduction: In one example, ≈25,000\approx 25,000≈25,000 text tokens were compressed into ≈2,700\approx 2,700≈2,700 image tokens.
  • Financial Savings: Based on current Fable pricing, this results in an end-to-end bill reduction of 59% to 70% (reaching 72–74%72\text{--}74\%72–74% for highly compressed requests).

[!IMPORTANT] Focus on tokens, not dollars. While pricing fluctuates, the reduction in token count is a constant technical advantage.

🛠️ How it Works

The transformRequest pipeline processes text by:

  1. Minifying whitespace.
  2. Reflowing text into full rows.
  3. Marking original newlines with the ↵ symbol.
  4. Adding an OCR instruction banner at the top of the render.

Example of a transformRequest output: system prompt + tool docs reflowed into one dense 1573×1248 page, instruction banner on top, ↵ marking original newlines

🧪 Benchmarks & Demos

Fable 5 (The Optimized Target)

Fable 5 demonstrates a 100/100 reading accuracy on clean evals.

  • The Test: Counting specific phrases across 39 filler files and performing multi-step ledger arithmetic (8037→⋯→15,0218037 \rightarrow \dots \rightarrow 15,0218037→⋯→15,021).
  • The Result: pxpipe matched grep ground truth line-for-line.
  • Cost Comparison:
    • Plain Claude: $42.21 (Context 96% full)
    • pxpipe: $6.06 (Plenty of context remaining)

Note: A slight trade-off was observed in format compliance; the imaged arm occasionally required a follow-up nudge to adhere to a specific one-line output format.

Opus 4.8 (The Baseline)

Opus is disabled by default as pxpipe is tuned for Fable.

  • Success: Successfully fixed a failing test suite with a fraction of the tokens.
  • Failure: Could not perform the "phrase-count" task on imaged filler files. Opus correctly admitted it couldn't read the image rather than fabricating a number.

⚠️ Critical Limitations

Not all data should be imaged. There is a documented lossy limit regarding precision.

  • Do NOT image: IDs, hashes, secrets, or exact numerical values.
  • Safe to image: General documentation, system prompts, and older history.

The Risk: In "needle-in-a-haystack" tests using 12-character hex strings, Opus scored 0/150/150/15 and Fable 5 scored 13/1513/1513/15. The failure mode is silent confabulation (providing a plausible but incorrect value) rather than an error message.

🚀 Quick Start

You can deploy the proxy in about 30 seconds:

# 1. Start the proxy
npx pxpipe-proxy 

# 2. Point Claude Code to the local proxy
ANTHROPIC_BASE_URL=http://localhost:47821 claude

Dashboard: Visit http://127.0.0.1:47821/ to monitor:

  • Tokens saved and per-session statistics.
  • Side-by-side text →\rightarrow→ image conversions.
  • Global kill switch and model selection (including GPT 5.5/5.6).

Model Routing

pxpipe only images requests for Fable (PXPIPE_MODELS=claude-fable-5). To ensure byte-exact accuracy for specific tasks, route them to a non-Fable model:

CLAUDE_CODE_SUBAGENT_MODEL=claude-sonnet-4-6