All posts

Freeze, then settle: how SaaScaffold charges credits for AI tasks

Three rows of blocks showing credits frozen, settled and released

The problem with charging at the end

An AI video can take minutes to generate. A provider can time out, return an empty file, or report success before its file is downloadable. In the meantime, a customer with credits for three videos can submit ten jobs. SaaScaffold protects that balance by freezing credits when it accepts a task and settling them when it knows the outcome.

Quote before accepting

The site quotes the price in its own integer credits, based on its configured model price and inputs such as duration or the number of images. The customer sees the quote before confirming. If the model price changes between quote and submission, the customer must review the new price. Provider costs and the site’s credit price are configured separately.

Freeze on acceptance

Task creation, the credit hold and the durable work record are written in one database transaction. The hold checks the available balance in that transaction, so concurrent submissions cannot overdraw it. Frozen credits are visible in the account and unavailable to other tasks while the work is pending.

Settle after saving and checking the result

The provider’s success response starts result handling. The task worker checks the output, saves text or copies media into storage controlled by the site, then records the outcome and settles the hold. If configured review withholds some or all of a generated result, the site can still charge the original quote once under its applicable terms. For the main flow and the supported providers, see AI tasks on SaaScaffold.

Release only on a trusted ending

A confirmed failure or a safe cancellation can release the held amount. A timeout alone leaves the outcome unknown: the site keeps checking and retains the hold in the meantime. An operator resolving a stuck task records the reason and the credit outcome in the audit trail.

Retries without double effects

Queues redeliver work and webhook senders retry events. SaaScaffold uses unique operations for balance changes so reprocessing a message leaves the original mutation in place. Payments use the same ledger. See one ledger for four payment providers for the payment-side example.

What customers see

The account records each freeze, deduction or release alongside the related task and status. Customers can see why their available balance changed while a job was running.

Sources and further reading