AI operations
Deduct credits for a generation, agent run, or tool call after your service measures it.
AI and SaaS usage credits
Keep credit balances separate from usage metering. Your product decides when a generation, tool call, or feature consumes value; XferAPI records the resulting movement and balance.
Measure tokens, calls, time, or another product unit where the usage occurs.
Submit a balanced transfer for the exact amount your product decided to consume.
After a timeout, resend the exact same transfer ID, scene, and payload directly.
Read current, future, permanent, and batch views for the account.
Common credit models
XferAPI stores the result of your policy. It does not replace subscription billing or decide how usage is priced.
Deduct credits for a generation, agent run, or tool call after your service measures it.
Issue periodic credit grants with an optional start or expiry boundary.
Keep a team account or distribute credits across individual member accounts.
Reverse the complete charge when the underlying product operation must be undone.
Keep the integration boundary explicit so product policy does not leak into the ledger API.
No. Your backend measures the event and submits the amount to move. XferAPI validates and records that balance operation.
Yes. Issue the allowance with an expiry timestamp. Expired value is excluded from available balance at the Unix-second boundary.
For one ordinary account and asset, XferAPI automatically spends active batches with the earliest non-zero expiry first, then permanent balance. Future and expired batches are not spendable. A source entry cannot select a specific batch, and relative order among batches with the same expiry is not part of the API contract. Use separate assets when paid and promotional balances need distinct business priority or provenance.
Resend the exact original transfer ID, scene, and payload directly. The same rule applies to internal_error, service_unavailable, and transfer_state_conflict; do not create a new ID or require a read request first.
insufficient_balance and execution-time amount_out_of_range are terminal transaction failures. That ID-and-scene pair can never succeed, so fix the condition and use a new transfer ID for the next charge attempt.
No. Payment collection, invoicing, plan selection, and pricing logic remain outside XferAPI.
Keep metering and pricing in your product, then use XferAPI to execute and inspect the resulting credit movement.