Skip to content

feat(claude): Claude Code status line showing Fireworks savings - #17

Open
tarunipaleru wants to merge 1 commit into
fw-ai:mainfrom
tarunipaleru:feat/cc-fireworks-savings-statusline
Open

feat(claude): Claude Code status line showing Fireworks savings#17
tarunipaleru wants to merge 1 commit into
fw-ai:mainfrom
tarunipaleru:feat/cc-fireworks-savings-statusline

Conversation

@tarunipaleru

@tarunipaleru tarunipaleru commented Jul 30, 2026

Copy link
Copy Markdown

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.mjs

On each render Claude Code pipes a status-line JSON object ({ model, transcript_path, workspace, ... }) to the script on stdin. It then:

  1. parses the session transcript for actual per-request token usage (input / output / cache read / cache writes),
  2. computes the real Fireworks spend from the existing serverless pricing modules — the same rates fireconnect model list reports,
  3. 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 Anthropic cache read/write rates,
  4. renders a single line:
Screenshot 2026-07-30 at 2 38 34 PM
🔥 Fireworks · $0.28 spent (25 req) vs Anthropic $1.14 saved $0.86 75% · glm-5p2 · fireworks

Why this shape

  • Reuses existing modules (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.
  • firerouter has 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).
  • Pure core for testing: computation is split into an exported computeSavings(transcriptText) + renderStatusLine(ctx, text) so the logic is exercised without spawning a process. main() is a thin stdin/file wrapper.
  • Never crashes the status line — malformed input or missing transcripts fall back to a safe minimal line (a crashing status line command is worse than no status line).

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=1 for non-TTY / CI captures.

Tests

New test/cli/cc-fireworks-savings.test.mjs (10 cases, all passing):

  • Fireworks spend computed below Anthropic-equivalent cost, with exact expected values for a known token mix.
  • Equivalence map covers each Fireworks family → Anthropic tier; unknown slugs fall back to Sonnet.
  • costAtRates prices the same token mix at Anthropic cache rates.
  • firerouter case: a concrete dispatched model is priced as Fireworks, not skipped.
  • Dedup of repeated assistant message ids.
  • Non-assistant and malformed lines ignored; empty/null/garbage input returns zeros and never throws.
  • Render produces a single line with savings > 0; safe fallback with no transcript data.
node --test packages/setup-cli/test/cli/cc-fireworks-savings.test.mjs
# tests 10, pass 10, fail 0

Full-suite note: node --test test/**/*.test.mjs shows 8 unrelated failures on this machine, all environmental — deepagents-toml tests need tomllib (Python ≥3.11) and detectIncumbent tests 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

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>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant