Budgets
An app that can start paid work (the generate scope) spends the connected user’s tokens, within a spending limit the user sets.
- The user sets the limit on the consent screen when they connect your app, and can change it later in Account → Connected apps.
- Your app cannot create or raise a limit. No API call can.
- Every paid start is checked against the limit and the account balance before anything runs, and the quoted maximum is reserved.
Read the budget
Section titled “Read the budget”GET /v1/account returns spending_limit: amount, per_generation, period (month or fixed), used, held, remaining, resets_at and manage_url. It is null when the user has not given your app spending authority. See Spending limits.
Show the user what is left before you start work, and send max_cost with every start so a single request cannot use more than you expect.
When the budget is used up
Section titled “When the budget is used up”| Error | What your app should do |
|---|---|
402 spending_limit_reached |
Tell the user, and link to manage_url where they can raise the limit if they choose. |
403 spending_not_authorized |
The user has not allowed spending for this model and project. Link to manage_url. |
403 spending_limit_changed |
The user paused, revoked or let the limit expire. Link to manage_url. |
402 insufficient_balance |
The account needs more tokens. The user adds them in the app. |
Do not retry these: they do not change until the user acts. Every refusal is free.