This article presents possible use cases and corresponding sample flows that you can support. It provides a useful starting point as you plan your implementation.
Apps that offer AI features often show account owners how many credits they have left. The AI Credits API returns the full balance in a single call, so you can render it in a dashboard or settings page.
To display an account's AI credit balance:
periodicCredits.balance for remaining recurring credits and topUpCredits.balance for remaining top-up credits, then show the total available as periodicCredits.balance + (topUpCredits.balance ?? 0).creditBalanceBreakdown to display credits from each source separately.Before running an AI action that consumes credits, check whether the account has enough credits and prompt the account to top up if it doesn't.
To gate an AI feature on available credits:
periodicCredits.balance + (topUpCredits.balance ?? 0).