Skip to content

feat(account): balance says what is left on fal too - #85

Merged
protonspy merged 2 commits into
mainfrom
feat/balance-says-both-providers
Sep 27, 2026
Merged

protonspy merged 2 commits into
mainfrom
feat/balance-says-both-providers

Conversation

@protonspy

Copy link
Copy Markdown
Owner

No description provided.

`balance` asked PixelLab and stopped there, which was the whole answer while
PixelLab was the only provider that could say. The question a person asks before
a paid run is about the account they are about to spend from, and there are two.

Where a fal key is configured the command now prints `fal credits: $7.37`
beside the generations and the PixelLab credits. Where there is no fal key it
prints nothing about fal and sends no request: fal is optional, and a line about
a provider an account does not have reads as a fault.

Not the documented route. `GET /v1/account/billing?expand=credits` on api.fal.ai
answers 403 authorization_error to the key this tool holds — that key is API
scope and billing is admin scope, and asking for a second, wider key so a free
line can be printed is the worse trade. What fal's own dashboard reads takes the
key we already have:

  GET https://rest.alpha.fal.ai/billing/user_balance   Authorization: Key <FAL_KEY>
  -> 200  7.3747928

Undocumented, and the host says `alpha`, so the code treats it as a ceiling
rather than a contract: no key, an HTTP error, a body that is not a number, and
a number that is not finite all come back as `fal: not reported`, and none of
them can cost the PixelLab half of the answer. `inf` and `nan` parse, and a
balance shown as `$nan` reads as a figure the account holds.

In `--json` the PixelLab keys stay at the top level and fal goes under `fal`, so
nothing reading the existing shape by name has to change; configured-and-silent
is `{"credits_usd": null}` rather than an absent key, which is how a parser tells
it from an account with no fal at all.

specs/provider-core R5.4, R5.5. Note n-0062.
Verified with scc validate --checks --pr: 1836 passed, 58 skipped, coverage
95.32%, ruff check and format clean, artifacts clean. Confirmed live against the
account: three lines, the fal one reading $7.37.
@protonspy
protonspy merged commit 17b183e into main Sep 27, 2026
2 checks passed
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