falaw.account#
Account health probe.
fal_client swallows the JSON body of its 403s, so a locked-account error
looks identical to “wrong API key” or “model is busy.” health_check()
makes a tiny, idempotent request to the fal storage endpoint and returns a
typed AccountStatus so the caller can distinguish:
account is locked / unverified →
AccountStatus.lockedis Truebad credentials →
AccountStatus.unauthorizedis Trueeverything looks fine →
AccountStatus.okis Truenetwork / unknown error → all flags False,
errorpopulated
Use this before a long render to fail fast with a useful message:
from falaw.account import health_check
status = health_check()
if not status.ok:
raise SystemExit(status.message_for_user())
Functions
|
Probe the fal storage endpoint and return a typed |
Classes
|
Outcome of |
- class falaw.account.AccountStatus(ok, locked, unauthorized, status_code, detail, url, error)[source]#
Bases:
objectOutcome of
health_check().- error: str | None#
reprof the underlying exception whenokis False and the failure isn’t a recognized lock/unauth (e.g. network error).
- falaw.account.health_check(*, probe_url='https://rest.fal.ai/storage/auth/token?storage_type=fal-cdn-v3', timeout_s=10.0, api_key=None)[source]#
Probe the fal storage endpoint and return a typed
AccountStatus.- Parameters:
probe_url (
str) – Endpoint to probe. Default is the storage-auth-token endpointfal_clientuses internally; small, idempotent, requires auth.timeout_s (
float) – Network timeout.api_key (
str|None) – Optional override ofFAL_KEY. Falls back to a key bound withfalaw.using_fal_credentials(), then the env var.
- Return type:
- Returns:
AccountStatuswithok=Truewhen the probe succeeded.