feat(claude): Claude Code status line showing Fireworks savings - #17
Open
tarunipaleru wants to merge 1 commit into
Open
feat(claude): Claude Code status line showing Fireworks savings#17tarunipaleru wants to merge 1 commit into
tarunipaleru wants to merge 1 commit into
Conversation
Adds `bin/cc-fireworks-savings.mjs`, a Claude Code status-line command that surfaces live cost savings from routing through Fireworks. On each render Claude Code pipes the session transcript to the script, which: - parses actual per-request token usage (input / output / cache read / write) - computes the real Fireworks spend from the existing serverless pricing modules (the same rates `fireconnect model list` reports) - compares it to what the same token mix would cost on the Anthropic-equivalent tier at list prices (Opus for GLM, Sonnet for Kimi, Haiku for DeepSeek, Fable for FireRouter), including cache read/write rates - renders a single line, e.g.: 🔥 Fireworks · $0.28 spent (25 req) vs Anthropic $1.14 saved $0.86 75% · glm-5p2 · fireworks This closes the gap noted in the README's "Claude Code pricing estimates" section: Claude Code's in-UI cost column uses Anthropic list prices and overstates spend for Fireworks users. The status line shows the real bill and the savings vs. paying Anthropic directly for the equivalent tier. Notes: - Reuses pricing/usage/model-id modules rather than hardcoding rates, so it tracks catalog updates automatically. - `firerouter` rows (no static rate) are priced against the concrete serverless model the transcript recorded, when available; otherwise skipped. - Computation is split into a pure, exported `computeSavings` + `renderStatusLine` for unit testing without spawning the process. - Never crashes the status line — malformed input / missing transcripts fall back to a safe minimal line. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
Adds a Claude Code status-line command that surfaces live cost savings from routing through Fireworks, closing the gap noted in the README's "Claude Code pricing estimates (important)" section: Claude Code's in-UI cost column uses Anthropic list prices and overstates spend for Fireworks users, and FireConnect can't override that column. This puts the real bill — and the savings vs. paying Anthropic directly — in the status bar instead.
packages/setup-cli/bin/cc-fireworks-savings.mjsOn each render Claude Code pipes a status-line JSON object (
{ model, transcript_path, workspace, ... }) to the script on stdin. It then:fireconnect model listreports,Why this shape
pricing.mjs,model-specs.mjs,usage.mjs,incumbent-detect.mjs) rather than hardcoding rates, so it tracks catalog/pricing updates automatically — no second source of truth to keep in sync.firerouterhas no static rate, so for router rows the script prices against the concrete serverless model the transcript recorded, when available; rows it can't price are skipped (never counted as zero-cost savings).computeSavings(transcriptText)+renderStatusLine(ctx, text)so the logic is exercised without spawning a process.main()is a thin stdin/file wrapper.Wiring
Add to
~/.claude/settings.json:{ "statusLine": { "type": "command", "command": "node /path/to/fireconnect/cli/packages/setup-cli/bin/cc-fireworks-savings.mjs", "padding": 0 } }Set
CC_STATUSLINE_NOCOLOR=1for non-TTY / CI captures.Tests
New
test/cli/cc-fireworks-savings.test.mjs(10 cases, all passing):costAtRatesprices the same token mix at Anthropic cache rates.fireroutercase: a concrete dispatched model is priced as Fireworks, not skipped.Full-suite note:
node --test test/**/*.test.mjsshows 8 unrelated failures on this machine, all environmental —deepagents-tomltests needtomllib(Python ≥3.11) anddetectIncumbenttests need live Anthropic credentials. None touch the status-line code path.Files
packages/setup-cli/bin/cc-fireworks-savings.mjs— the status-line command (new)packages/setup-cli/test/cli/cc-fireworks-savings.test.mjs— unit tests (new)README.md— documents the status line under "Claude Code pricing estimates"🤖 Generated with Claude Code