Skip to content

feat: add CLI cost preview (openfusion ask --estimate) - #109

Open
shrdgn wants to merge 1 commit into
mainfrom
claude/vibrant-archimedes-vu7mux
Open

feat: add CLI cost preview (openfusion ask --estimate)#109
shrdgn wants to merge 1 commit into
mainfrom
claude/vibrant-archimedes-vu7mux

Conversation

@shrdgn

@shrdgn shrdgn commented Jul 15, 2026

Copy link
Copy Markdown
Owner

Summary

  • Adds a --estimate flag to openfusion ask that prints the calls/tokens/$ a prompt would cost — reusing the existing openfusion.estimate.build_estimate + openfusion.pricing.get_prices logic that already backs POST /v1/estimate — without running the prompt or requiring an upstream API key.
  • This closes the "CLI cost preview" item that ROADMAP.md's "Next" section had been tracking since the estimate endpoint shipped.
  • Updates README/CHANGELOG/ROADMAP to document the new flag.

Why it matters

POST /v1/estimate and the playground's live cost preview already existed, but there was no way to preview cost from the terminal before running openfusion ask — you had to just run it and see what it cost. This closes that gap with a small, self-contained change that reuses existing, well-tested estimate/pricing code paths.

Test plan

  • pytest -q — 454 passed (4 new tests covering _print_estimate cost/no-pricing output and that run_ask(..., estimate=True) skips execution and the API-key check)
  • ruff check .
  • mypy openfusion/ --ignore-missing-imports --disable-error-code import-untyped --exclude openfusion/cli.py
  • Manual: python -c "from openfusion.cli import _ask_cli; _ask_cli(['--help'])" shows the new --estimate flag

Generated by Claude Code

Wires the existing /v1/estimate logic (openfusion.estimate.build_estimate +
openfusion.pricing.get_prices) into a new `--estimate` flag on `openfusion
ask`, so the roadmap's planned CLI cost preview works without running the
prompt or requiring an upstream API key.
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.

2 participants