Files
craft-ai-integrations/docs
Jeremy 2988987c1a feat: show a cost estimate on the plan, before consent (#168)
`AiClient::plan` now works out a `CostEstimate` from the saved model's
`pricing` and the request, so an app can show the price beside the
disclosure before the person agrees. It reads no key and contacts
nothing. `Plan::estimate()` returns it.

The rule lives in `craft_ai_core::cost::estimate`: the per-image price
times the results asked for. A token price above zero gives `None`,
because the reply's token count is unknown before sending. Two stated
zero token prices give zero. A missing price or an overflow gives
`None`, never a guess.

History still records an estimate: the adapter's own figure where it
gives one, otherwise the plan's, including on a refusal before the
adapter is built.

`cost_text` keeps part-cent digits, so 0.039 USD no longer reads 0.03.

FLUX.1 Fill [pro] carries $0.05 per image, from BFL's price page
(cited in the code). Gemini, FLUX 3 and Seedance stay unpriced: their
publishers price by resolution tier or by token.
2026-11-09 08:47:03 +01:00
..