Money fields
Every amount is an integer number of micro-USD, in a field whose name ends inMicroUsd. One US dollar is 1,000,000 micro-USD, so 42000 is USD 0.042.
Integers keep amounts exact; convert to dollars only for display.
A generation’s billing
Every generation has abilling object:
Billing states
While a generation is
held, hold.state reports where it stands. It reports
facts, not a prediction of the charge:
For a
byok generation, quotedMicroUsd is 0, heldMicroUsd is 0 while
held, and chargedMicroUsd is 0 once charged.
What’s charged
- The charge follows the work the provider actually reports, so it can differ from the quote. In rare cases, it can be higher than the quote.
- A failed output isn’t charged for its output, but a generation is still charged for billable work that actually happened, such as accepting the request.
- Cancelling stops unfinished outputs. Outputs that a provider already finished are kept and charged.
Check the cost before you start
To see a cost before you start, request a quote withPOST /v1/generations/quote. It holds nothing. For details, see
Models.
To cap a create, send maxCostMicroUsd. If the quote is higher, the create
fails with 402 cost_limit_exceeded and starts nothing. maxCostMicroUsd caps
the quote, not the final charge.
A create can also fail before it starts with these errors:
Read your balance
GET /v1/balance returns your organization’s funds. It needs the
account:read scope. Add projectId to include that project’s monthly budget.
A limit’s
limitMicroUsd can be null. If your organization’s balance isn’t
available, the response is 503 unavailable.
The balance is a point-in-time read. A generation’s quote and admission decide
whether it can start.