Spend limits
Set daily and monthly spend limits for an API key, an organization member or the whole account. Depending on your settings, reaching a limit can reject new requests or trigger an email while allowing requests to continue. Days and months follow the WIB calendar: a day ends at midnight WIB and a month on the last day of the calendar month, whatever time zone you are in.
Where each limit is set
Section titled “Where each limit is set”| Limit | Where | Who can set it |
|---|---|---|
| Per API key | The API Key page, under Set limits (optional) when you create the key | Whoever creates the key |
| Per member | Members, in the Limits column for that person | People with the Members permission |
| Whole account | Shown under Spend limits on the Overview page | Ask us through Support |
A member’s limit counts the spending of every key issued to that person. A daily limit can’t be higher than the monthly one.
On a key, each of Daily and Monthly is one of:
- Account default: the account’s default for keys, which is no limit unless one was agreed with us;
- No limit;
- Amount: the rupiah amount you type.
What counts toward a limit
Section titled “What counts toward a limit”Everything already charged in the current day or month, plus the most the new request could cost (its reservation). A request can therefore be refused while you are still a little under the limit, if its estimated maximum cost would exceed it. Sending a smaller max_tokens reserves less.
When a limit is reached
Section titled “When a limit is reached”For key and member limits, you choose what happens under When reached:
- Refuse: new requests are refused until the day or month ends. This is the default.
- Warn only: requests keep going and we only send the email below.
The account limit always rejects new requests when reached.
A refused request gets 402 with the code spend_cap_exceeded, and the message says which limit was reached, for example “this key’s daily spend cap does not cover this request”. Limits are checked in the order key, member, account, so the message names the first one the request would break.
Emails
Section titled “Emails”We send an email when spending reaches 80% of a limit and again at 100%, once per day or month:
| Limit | Who gets the email |
|---|---|
| Key | The person the key was issued to, or the account’s owners for a key not issued to anyone |
| Member | That member and the account’s owners |
| Account | The account’s owners |