AI and SaaS usage credits

A usage credits API for AI and SaaS products

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.

Meter in your app

Measure tokens, calls, time, or another product unit where the usage occurs.

Charge in XferAPI

Submit a balanced transfer for the exact amount your product decided to consume.

Retry uncertainty

After a timeout, resend the exact same transfer ID, scene, and payload directly.

Show the balance

Read current, future, permanent, and batch views for the account.

Common credit models

One accounting primitive, several product policies

XferAPI stores the result of your policy. It does not replace subscription billing or decide how usage is priced.

AI operations

Deduct credits for a generation, agent run, or tool call after your service measures it.

Plan allowances

Issue periodic credit grants with an optional start or expiry boundary.

Shared pools

Keep a team account or distribute credits across individual member accounts.

Usage reversal

Reverse the complete charge when the underlying product operation must be undone.

Usage-credit questions

Keep the integration boundary explicit so product policy does not leak into the ledger API.

Does XferAPI meter model or API usage?

No. Your backend measures the event and submits the amount to move. XferAPI validates and records that balance operation.

Can a monthly allowance expire?

Yes. Issue the allowance with an expiry timestamp. Expired value is excluded from available balance at the Unix-second boundary.

Which credits are spent first?

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.

How should a timed-out credit charge be retried?

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.

What happens after an insufficient-balance charge?

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.

Is this subscription billing?

No. Payment collection, invoicing, plan selection, and pricing logic remain outside XferAPI.

Connect your first credit balance

Keep metering and pricing in your product, then use XferAPI to execute and inspect the resulting credit movement.