Reserve & settle support in the Agent SDK
Reserve and settle is now built into the Agent SDK. Add a reserve option when you wrap your model client. The SDK then holds credits for the whole workflow and deducts only what the workflow actually used.
π What's new?
- One reservation per workflow: The first model call places a hold for the amount you set. Later calls spend directly from that hold.
- Settle on close: When you call
close(), the SDK deducts what the workflow used and returns the rest to the customer's balance in one step. - Refuse before the first call: If the balance can't cover the hold, the workflow is refused before any AI call is made.
- Automatic expiry: If a workflow is abandoned, its credits are automatically returned when the hold expires (by default after 1 hour, configurable up to 24 hours using the
ttlSecondsparameter).
π‘ Why it matters
- No double spending: Agents that run in parallel can't draw on the same credits, because each workflow's hold leaves the available balance as soon as it's placed.
- Deduct only real usage: Usage is deducted once, at settle. Failed calls cost nothing, and unused credits go back to the customer.
- Built into the calls you already make: Reservations, settlements and expiry all run through the wrapped client, so you don't need to build or maintain your own hold-and-release logic.
βοΈ Get started
- Set the hold: Add
reservewith the most the workflow can cost and, if needed, how long it can run. - Run the workflow: Make model calls through the wrapped client as usual.
- Settle: Call
close()when the workflow ends.
See Reserving credits for a task and Reserve and settle for how reservations, expiry and the credit ledger work.
π¦ Availability
Reserve & settle support is available in the Stigg Agent SDK v0.7.24 or later.