Account
Limits
How requests are limited, and how you find out.
Rate limits
Each key has a requests-per-minute limit: the platform default, or the number you set on the key. Every response tells you where you stand:
Requests allowed per minute.
Requests left in the current minute.
Seconds to wait, sent with a 429 .
The default limits are published with the API launch and shown on each key in the console.
Spend caps
•
A key cap stops that key for the rest of the calendar month. Other keys carry on.
•
The
organization limit under
Billing stops all its keys together.
•
A key's model list rejects any other model with a 403 .
A request refused by a cap returns 402 and is not charged.
Handling 429 and 5xx
Retry only when the failure may be temporary ( 429 and 5xx ), wait longer each time, and give up after a few tries:
async function call(url, init, tries = 5) {
for (let attempt = 0; attempt < tries; attempt++) {
const response = await fetch(url, init);
if (response.status !== 429 && response.status < 500) return response;
const wait = Number(response.headers.get("retry-after")) || 2 ** attempt;
await new Promise((r) => setTimeout(r, wait * 1000));
}
throw new Error("Still failing after retries");
}
For model requests you often don't need to retry yourself: set
fallback models and the request moves on by itself.
Previous
Usage and billing