diff --git a/README.md b/README.md index e4a4890..743bb4e 100644 --- a/README.md +++ b/README.md @@ -1,23 +1,24 @@ # pxpipe -**Cut Claude Code input-token spend by rendering bulky context as images.** +**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.** -Anthropic bills an image by its pixel dimensions, not by how much text is -inside it. Dense content (code, JSON, tool output) packs ~3.1 chars per +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. pxpipe is a local proxy that exploits that gap: it rewrites the bulky parts of your request (system prompt, tool docs, older history) into compact PNGs before the request leaves your machine. Savings are **workload-dependent** — pxpipe wins on token-dense content and -leaves sparse/small requests untouched — so this is a measured snapshot, not a -constant. Across production traces the **end-to-end bill drops ~59–70%** -(**~72–74%** on the requests it actually compresses), with full dollar math: -input + cache writes at 1.25× + cache reads at 0.1× + output at 5×, every -request measured against its own `count_tokens` counterfactual. Two snapshots: a -13,709-request log turned $100 into ~$41 (59% end-to-end; ~$28 / 72% on the -7,756 it compressed); a later 8,904-compressed-request trace measured ~70% -end-to-end / ~74% compressed. Reproduce it on your own traffic from +leaves sparse/small requests untouched — so these are measured snapshots, not +constants. The primary, durable result is **input-token reduction**: dense +system prompts, tool docs, and history go in as compact images instead of text +(the example above is ≈25k text tokens rendered as ≈2.7k image tokens), every +request measured against its own `count_tokens` counterfactual. **Dollars are +downstream of that** — at current Fable list prices the token cut lands as a +**~59–70% lower end-to-end bill** (~72–74% on compressed requests; full pricing +math in the FAQ). But list prices can change tomorrow and the token count +won't, so tokens — not dollars — are the number to watch. Reproduce both from `~/.pxpipe/events.jsonl`. This is what the model sees instead of text: diff --git a/src/dashboard/fragments.ts b/src/dashboard/fragments.ts index 54b5d34..42370a9 100644 --- a/src/dashboard/fragments.ts +++ b/src/dashboard/fragments.ts @@ -181,7 +181,7 @@ export function renderSessionSummaryFragment(data: CurrentSessionPayload): strin `
${bigNum} ${word} sent to Claude
` + `
` + `${kFmt(ppTotal)} tokens actually sent vs ${kFmt(textTotal)} if it were all plain text. ` + - `Your messages and Claude's replies are never compressed.` + + `Your latest messages and Claude's live output are never compressed.` + `
` + `
` + `Input context compressed ${inputPct.toFixed(0)}% ` + @@ -254,7 +254,7 @@ export function renderHeaderFragment(s: StatsPayload, port: number): string { numFmt(s.saved_input_tokens), 'vs sending the same context as text', 'pos', - 'Bulky context (system prompt, tool output, old turns) sent as compact images instead of text. Cache-aware, input side only — your replies are never compressed.', + 'Bulky context (system prompt, tool output, old turns) sent as compact images instead of text. Cache-aware, input side only — recent turns and the live output stay text.', ) + statTile( 'Estimated saved',