@CycleDecoded: 离谱了兄弟们,GitHub 刚冲上趋势的一个骚操作,直接把大模型计费系统给“卡BUG”了。 这玩意叫 pxpipe(MIT协议),是一个专治 Claude Code 账单刺客的本地开源代理工具。原理简直绝了:大模型按字数算文本 Token…
摘要
pxpipe是一个本地开源代理工具,通过将大量文本(如系统提示、代码、日志)渲染为PNG图片并输入大模型的视觉通道,利用图片按像素计费而非按字数计费的特点,成功将Claude Code的账单降低约70%。该工具完美适配Fable 5模型,原理巧妙且全自动化,但属于有损压缩,不适合敏感数据。
查看缓存全文
缓存时间: 2026/07/10 16:14
离谱了兄弟们,GitHub 刚冲上趋势的一个骚操作,直接把大模型计费系统给“卡BUG”了。
这玩意叫 pxpipe(MIT协议),是一个专治 Claude Code 账单刺客的本地开源代理工具。原理简直绝了:大模型按字数算文本 Token,但图片是按固定像素算钱的。它干脆把你那堆又长又占位置的系统提示词、代码和历史日志,直接截成一张密密麻麻的 PNG 图片,扔给大模型的视觉通道硬看。这波有点狠,直接降维绕过了高昂的文本计费!
账单暴跌70%:实测 $42 的账单直接干到 $6
降维打击计费:图片按面积算钱,字塞越密越省
纯本地自动化:自动拦截请求转图,原流程不用改
白嫖党狂喜:完美适配最新的 Fable 5 模型
不过这招属于有损压缩,哈希值或密码等敏感数据还得老老实实走文本,长段上下文用它平替就完事了。
GitHub:https://github.com/teamchong/pxpipe… 还在等啥,自己去看。
如果想直观看看这是怎么操作的,推荐看下这个视频,里面详细解释了如何利用这个工具直接把 Fable 5 的使用成本砍掉一半:This GitHub Repo Cuts Your Fable 5 Bill in Half。
teamchong/pxpipe
Source: https://github.com/teamchong/pxpipe
pxpipe
Cut Claude Code’s input tokens by rendering bulky context as images — the same system prompt, tool docs, and history, in a fraction of the tokens.
An image’s token cost is fixed by its pixel dimensions, not by how much text
is inside it. Dense content (code, JSON, tool output) packs ~3.1 chars per
image-token vs ~1 char per text-token on real Claude Code traffic. The
reader is the same vision channel that Anthropic’s computer use already
relies on for screenshots. pxpipe is a local proxy that uses that channel
for context: it rewrites the bulky parts of each request into compact PNGs
before it leaves your machine. At current Fable
list prices that lands as a ~59–70% lower end-to-end bill — but prices
move and workloads differ, so the durable number is the token cut itself,
measured per-request against a free count_tokens counterfactual in
~/.pxpipe/events.jsonl.
This is what the model sees instead of text:

~48k chars of system prompt + tool docs: ≈25k tokens as text, ≈2.7k image tokens as this page. Real pipeline output; the model reads renders like this at 100/100 (see benchmarks).

Eight years of context growth, in characters. Every text line tops out near
~4M chars (a 1M-token window at ~4 chars/token); the orange point is the
same Fable 5 1M window read through pxpipe images — ~18M chars at the
measured 18.3 chars/vision-token, 4.6× the text ceiling. The density and
multiplier are measured from a live render at generation time, not
hand-typed: regenerate with npx tsx scripts/gen-context-chart.ts
(source).
Demo
Fable 5 (the default, 100/100 reader) — plain left, pxpipe right:
https://github.com/user-attachments/assets/1c8ee63a-fcd7-4958-917b-da788d718349
pxpipe counts an exact token 10/10 across 39 imaged filler files
(matches grep line-for-line), gets the multi-step ledger arithmetic right,
and ends the session at 6.06** with context to spare (73.5k/1M) vs
**42.21 at 96% full. One caveat visible in the clip: the pxpipe arm
needed a nudge to match the requested one-line output format.
Opus 4.8 (disabled by default) — same layout:
https://github.com/user-attachments/assets/f4e50137-31b5-426f-a6ed-b83f829b4a2c
Text needles read fine on both arms; the imaged phrase-count doesn’t read on Opus — and pxpipe says so instead of fabricating a number. That misread rate is why Opus is opt-in.
Try it (30 seconds)
npx pxpipe-proxy # proxy on 127.0.0.1:47821
ANTHROPIC_BASE_URL=http://127.0.0.1:47821 claude # point Claude Code at it
Dashboard at http://127.0.0.1:47821/: tokens saved, every text→image conversion side by side, kill switch, live model chips. Responses stream normally — pxpipe compresses the request only, never the model’s output. Recent turns stay text; the system prompt, tool docs, and older bulk history are imaged.
The honest part
- It is lossy. Exact 12-char hex strings in dense imaged content: 13/15 on Fable 5, 0/15 on Opus — and misses are silent confabulations, not errors. Byte-exact values (IDs, hashes, secrets) must stay text; recent turns do. A dedicated verbatim-risk guard is not built yet.
- Escape hatch: subagents on non-allowlisted models pass through as
text — route byte-exact work there
(
CLAUDE_CODE_SUBAGENT_MODEL=claude-sonnet-4-6, ormodel: sonnetin agent frontmatter). - Real work: SWE-bench Lite pilot 10/10 both arms at −65% request
size; SWE-bench Pro 14/19 ON vs 15/19 OFF at −60%, verdicts agree
18/19, and the single split re-resolved 3/3 on replication — run-to-run
variance, not compression. Small n; receipts in
eval/. - Workload-dependent. Wins on token-dense content (~1 char/token), loses money on sparse prose (~3.5 chars/token); a profitability gate (calibrated on N=391 production rows) images only where the math wins.
- Client-dependent, not product-name-dependent. Savings track uncached
bulk the client still re-sends as text. Claude Code re-sends system + tools
- history on
/anthropic/messagesand typically lands ~60–70%. Codex on/v1/responsesis supported; when the prompt is already ~98%cached_tokens, only the static slab (and rare history collapses) remain to image, so Saved can honestly sit near 1%. The same Responses path saves tens of percent when history collapse fires, and an OpenAI client that re-sends the full transcript as plain text each turn is in the same high- savings class as Claude Code. Details and measured splits: docs/CACHING_AND_SAVINGS.md.
- history on
- Model scope: default
PXPIPE_MODELS=claude-fable-5. Sol, Opus 4.7/4.8, GPT 5.5, and Grok are opt-in only (dashboard chips orPXPIPE_MODELS) — not good enough as silent defaults for imaged context. The exact Sol id still matters when opted in: sibling variants such asgpt-5.6-terrado not inherit Sol’s allowlist or render profile.PXPIPE_MODELS=offdisables imaging. Everything else passes through byte-identical. On the GPT path, tool definitions stay native JSON and no Anthropiccache_controlmarkers are used. - Per-model rendering: opt-in
gpt-5.6-solcurrently uses a 126-column, 6×11 JetBrains Mono profile; Claude keeps its 312-column 5×8 Spleen profile. These are selected by exact model id, including history pages and profitability math. Sol recall caveat: raw-image calls scored 0/4 exact with four inventions at both current 6×11 and old shared 5×8; 6×11 passed gist/guard, while 5×8 also missed gist. Production’s verbatim fact-sheet remains a text fallback for extracted identifiers. An effective 9×12 Sol retune is rendered but not yet model-tested, so the current Sol geometry is operational—not recall-validated. Sol receipts and profile evidence. - Grok (opt-in): measured 9×12 + factsheet. Off by default. Pure-image exact OCR at 5×8 fails (0/4 IDs); the densest tested pure-image arm that cleared 4/4 with zero confabulation was effective 9×12 / 84 columns at ~30% fixture savings. The fact-sheet remains attached as defense in depth. eval/grok-density/FACTSHEET_RESULTS.md.
Benchmarks (reproducible)
Measured with novel random-number problems the model cannot have memorized:
| test | N | text | pxpipe (image) | tokens |
|---|---|---|---|---|
novel arithmetic, claude-fable-5 | 100 | 100% | 100% | −38% |
novel arithmetic, claude-opus-4-8 | 100 | 100% | 93% | −38% |
| gist recall A/B (decisions, values, paths, names, negations; with distractors; 15k-45k char sessions), Fable 5 | 98/arm | 98/98 | 98/98 | - |
| state tracking (value mutated 3x, final/first/count), Fable 5 | 18/arm | 18/18 | 18/18 | - |
| confabulation on never-stated facts (lower is better), Fable 5 | 16/arm | 0/16 | 0/16 | - |
| verbatim 12-char hex recall, dense render, Opus | 15 | 15/15 | 0/15 | - |
| verbatim 12-char hex recall, dense render, Fable 5 | 15 | - | 13/15 | - |
SWE-bench run totals, receipts, and caveats:
eval/swe-bench/ ·
eval/swe-bench-pro/ ·
eval/needle-haystack/ ·
eval/gist-recall/ · analysis in
FINDINGS.md. (GSM8K scored 96% imaged, but it’s in training
data — memorized answers survive misreads — so we lead with the novel-number
evals.)
How it works
model id ──► render profile ──► wrap/reflow bulk context ──► PNG[] + exact-token factsheet
The proxy intercepts /v1/messages, rewrites eligible bulk into image
blocks, splices them back cache-friendly (static prefix preserved, prompt
caching keeps working), and forwards. Claude uses 1568×728 pages; GPT 5.6 Sol
uses 764px-wide portrait strips; opt-in Grok uses effective 9×12 cells. A
per-request estimator uses that same resolved profile, so sparse prose stays
text. Events log to ~/.pxpipe/events.jsonl.
Library use (no proxy)
import { renderTextToImages, transformAnthropicMessages } from "pxpipe-proxy";
const { pages } = await renderTextToImages(toolResultText); // pages[i].png: Uint8Array
const { body, applied, info } = await transformAnthropicMessages({
body: requestBytes,
model: "claude-fable-5",
});
options.keepSharp(block) pins blocks as text; options.emitRecoverable
returns the originals of imaged blocks. Pure-JS runtime (Node and
edge/Workers); @napi-rs/canvas is build-time only. Full API:
src/core/index.ts.
Development
pnpm install && pnpm test
pnpm run build # regenerates dist/
FAQ
Is the headline end-to-end, or only on the requests you touched? End-to-end, the whole bill. Most compression tools report savings only on the input slice they touched, which flatters the number. The end-to-end denominator is every production request: the small ones pxpipe correctly left untouched, all cache writes and reads, and all output tokens (which the proxy never compresses). On a 13,709-request snapshot that was 59% (100 → ~41); a later 8,904-compressed-request trace measured ~70%. Compressed-only runs higher (~72–74%) and is quoted separately, never as the headline. The exact figure is workload-dependent — reproduce it on your own log.
How is the math measured?
Both sides of the same request, at the same moment. For every /v1/messages
POST the proxy fires a free count_tokens probe on the original uncompressed
body (the counterfactual) in parallel with the real forward, and reads
Anthropic’s actually-billed usage block off the response. Both land in the
same row of ~/.pxpipe/events.jsonl, so there is no turn-count or
run-to-run confound. Dollar conversion uses Fable 5 list ratios: input ×1.0,
cache write ×1.25, cache read ×0.1, output ×5. Cache pricing is applied
identically to both sides, so the caching discount cancels and cannot be
double-counted as “savings”. Re-derive it yourself from the events log: the
formula and field names are documented in src/core/baseline.ts.
What does it actually compress? Three kinds of input blocks, each behind a profitability gate:
- large
tool_resultbodies (file reads, command output, logs) above ~6k chars of token-dense content - older collapsed history: turns behind the live tail get re-rendered as image pages, recent turns always stay text
- the static system prompt + tool docs slab
Everything else passes through byte-identical: your messages, recent turns,
the model’s output (it is the response, the proxy never touches it), sparse
prose, and anything too small to win. Models outside the allowlist pass
through entirely — the built-in default scope is Fable 5 only. Sol, Opus 4.8,
GPT 5.5, and Grok are deliberately opt-in via the dashboard or
PXPIPE_MODELS, never silently imaged. Sol joined that list after both its
6×11 profile and the old shared 5×8 profile scored 0/4 exact with four
confabulations in direct raw-image calls.
Has it ever failed for real, outside the benchmarks? Yes, once in weeks of daily use: the model recalled a person’s name from imaged chat history and got it confidently wrong. No error, just a plausible wrong name. That is the documented failure mode: exact strings in imaged content are not byte-safe. Coding sessions tolerate this because the agent re-reads files before editing; pure chat recall has no such check. This failure mode is measured, not anecdotal: the legibility audit quantifies exact-string recall off rendered pages (blind reads top out at 63% on dense identifiers, with every miss predicted by a glyph-confusability matrix) and documents the shipped mitigations — page geometry clamped to the API’s resample cap so billed pixels actually reach the vision encoder, and exact identifiers (SHAs, numbers) riding alongside as text.
Why are misses silent confabulations instead of read errors? Because model vision is not OCR: the image becomes patch embeddings, never discrete characters, so there is no per-glyph confidence to fail loudly on. When pixels underdetermine a glyph, the language prior fills the gap with something plausible. Mechanism and receipts: docs/NOT-OCR.md.
Didn’t DeepSeek-OCR show this doesn’t hold up in practice? No: it proved the channel works, using an encoder/decoder pair trained for the job. The skepticism dates from October 2025, when no stock production model could read dense renders; that changed with Fable 5 (0/15 verbatim hex on Opus 4.8 vs 13/15 on Fable 5, same pages). Timeline and per-model numbers: docs/NOT-OCR.md.
Why does the README read like an AI wrote it? Because one did. Most of this repo’s commits — the code and the docs — were authored by Opus/Fable agent sessions running behind pxpipe itself, reading their own collapsed history as image pages while they worked.
Limitations
- Lossy (above); verbatim recall from images is unreliable.
- PNG encoding adds latency to large requests before they leave.
- ASCII/Latin-1 well tested; CJK works but conservatively.
Roadmap
Rendering research is parked as of 2026-07-05: verbatim misreads are capacity-bound, not trick-bound, so no font/color/layout change fixes exact-string recall at profitable density. The why is in docs/NOT-OCR.md; the dated analysis and the three documented follow-up threads (glyph-style A/B with banked pages, runtime canary + re-fetch, surrogate-reader pre-flight) are in FINDINGS.md, 2026-07-05 entry. Watch condition: re-run the resolution sweep per model release; readable density moved ~4x in glyph area from Opus 4.8 to Fable 5, and a model that reads production cells near 100% means savings rise for free.
Still open, unchanged: whether imaged bulk stretches effective context (~2x the real content in the same 1M window), and whether a smaller active context improves long-task accuracy. Hypotheses, not claims — they ship as numbers with an n or they get cut.
License
MIT.
相似文章
@jianshuo: 看得见,才谈得上理解。我写了个 ccglass,npm 装上就能看到 Claude Code 背地里给大模型发了什么——系统提示词、48 个工具、token 账,全摊开。
ccglass是一个零依赖的本地日志反向代理和Web仪表盘,可以让你实时查看Claude Code等编码代理发送给大模型的系统提示、工具和token使用情况。
@VincentLogic: 这开源项目把 Claude Code 的成本砍了 25%。 它不做新模型,不做新 IDE。 就给 AI coding agent 画了张"代码地图"。 传统玩法:模型读完整个仓库 → 爆 token。 它的玩法:先把代码用 Tree-si…
一个开源项目通过Tree-sitter将代码解析成图结构并存入本地SQLite,为AI coding agent提供代码地图,从而减少token消耗和成本,平均节省57% token,成本降低25%。支持Claude Code、Cursor、aider等工具。
@vintcessun: 白天看到这个repo有点意思。 UltraCode-Shim把Claude Code的UltraCode模式(xhigh effort+动态workflow)代理到了任意付费模型上。 原理是本地跑一个纯stdlib的代理,自动加上Ultr…
UltraCode-Shim is an open-source tool that proxies Claude Code's UltraCode mode (xhigh effort + dynamic workflow) to any paid model via a local stdlib-only proxy, supporting dual-model orchestration with automatic routing by task difficulty.
@axichuhai: 发现一个能让 Claude 变得更好用的开源神器 只有一个65行的 Markdown 文件,GitHub 上已经冲到了 13万+ Star 灵感来自 Karpathy 说模型喜欢在不确定的时候瞎猜、把代码写得过度复杂、还会悄悄改掉不该碰的…
一个仅65行的开源Markdown文件,为Claude总结了4条编程铁律,帮助提升代码质量和节省token,GitHub上已获13万+ Star,灵感来自Karpathy。
@VincentLogic: Claude Code 的开源平替来了!OpenClaude 真香警告 之前一直觉得官方 Claude Code 只能连自家模型太受限,这个开源版直接打通任督二脉: 支持 DeepSeek、GPT-4、GLM 等任意模型 用法跟原版一模一…
介绍 OpenClaude 这个开源替代品,支持 DeepSeek、GPT-4 等多模型,并能通过 Agent Routing 功能智能分配任务,省钱高效。