feat(music): quote the price as an upper bound at fal's rate

Merged
SW
3mo ago
+31-16

Row 8 of the chat#1999 matrix. The client half of recoupable/api#853.

Two changes

Rate. CREDITS_PER_SECOND 0.5 → 0.2 and the 15-credit floor removed, matching the API exactly. fal charges $0.002/s and a credit is $0.01, so 0.2/s is fal's rate with no markup.

durationbeforeafter
10s$0.15$0.02
60s$0.30$0.12
120s$0.60$0.24
300s$1.50$0.60

Wording. Costs $0.12 for 60s (12 credits) → Up to $0.12 for 60s (12 credits). You are charged for the audio actually generated.

api#853 charges for the audio fal actually produced, and the model routinely stops short — our first songs averaged 39.9s against a 60s default. A fixed "Costs" would overstate what most generations are billed. An upper bound is safe in the only direction that matters: nobody is charged more than they were shown.

This is why the earlier "the quoted price must be final" reasoning no longer applies. It existed to stop the quote being a lie; the charge now only ever moves in the customer's favour.

On the duplicated constant

lib/music/const.ts restates the API's rate rather than fetching it, because the quote has to re-render on every slider drag. That was a deliberate call when the pricing shipped and it still holds — but it means this PR and api#853 have to land together or the form lies. The tests now name api#853 so the next person changing one finds the other.

Tests

47/47 green, both suites updated first and confirmed RED. tsc and eslint clean.

The form test now asserts the "up to" phrasing and the explanatory line, not just the number, so dropping the caveat while keeping the price would fail.

🤖 Generated with Claude Code

https://claude.ai/code/session_017fSvwazBitPfsTQvVqpi8q


Summary by cubic

Quotes music generation as an upper bound at fal’s rate and aligns the UI with the API. Previously: “Costs $X” at 0.5 credits/s with a 15-credit floor; now: “Up to $X” at 0.2 credits/s with no floor, and we state billing is for audio actually generated (e.g., 60s now shows $0.12).

  • Rollout
    • Deploy together with the API change (recoupable/api#853); otherwise the form quote will not match charges.
    • The rate is duplicated in lib/music/const.ts for responsive quoting; keep it in sync with the API when pricing changes.
    • Tests now assert the “Up to …” wording and the explanatory line.