How a generation is charged
- Submit: the estimate is held. When you create a generation, Codzen computes its estimate from the model’s prices and your
input, and holds that amount from your balance. If the balance does not cover the estimate, the request fails with402 insufficient_balanceand nothing is held. - Finish: the final cost is settled. When the generation succeeds, its final cost is computed from what it actually delivered. The difference from the estimate is settled: if the final cost is lower, the rest is returned to your balance; if it is higher, the difference is charged.
- Fail: nothing is charged. When the generation fails, for any reason, the whole estimate returns to your balance and the final cost is
"0.00".
The cost object
Every generation carries a cost object:
A generation can be billed by more than one price row, for example per second of output plus per second of input video, so
usage is always an array, even with one item.
Amounts are decimal strings, such as "0.40", so that they keep their exact value. Parse them with a decimal type rather than a floating-point number. The sum of amount over your generations is what you have spent; list your generations to reconcile it with your records.
Check your balance
Low and negative balance
Because a final cost can exceed its estimate, settling a generation can take your balance below zero. A negative balance is still your balance, shown as a negativeamount:
POST /generations fails with 402 insufficient_balance. Generations already in progress still finish. Top up in the console: the top-up first brings the balance back up from below zero, and new generations are accepted again as soon as the balance covers their estimate.

