Guides
Rate limits
Two independent limits protect the gateway and your spend.
Per-minute request limit
Inference requests (POST /v1/chat/completions, /v1/responses, /v1/messages, /v1/images/generations) are limited to 120 requests per minute per account. The window is fixed. Responses include these headers:
X-RateLimit-Limit: 120
X-RateLimit-Remaining: 117
X-RateLimit-Reset: 42
Retry-After: 42 # only on a 429X-RateLimit-Reset is the number of seconds until the window resets. Over the limit you receive 429 rate_limit_exceeded with Retry-After.
Plan spend windows
Your plan may also cap spend over a time window. When that cap is reached you receive 429 rate_limit_exceeded with a message naming your plan and window. Wait for the window to roll over or change plan in the dashboard. You can receive a warning notification as you approach the cap, if enabled.
Handling 429
import time, requests
def post_with_retry(url, headers, body, tries=4):
for attempt in range(tries):
r = requests.post(url, headers=headers, json=body)
if r.status_code != 429:
return r
wait = int(r.headers.get("Retry-After", 2 ** attempt))
time.sleep(wait)
return rRetry only on 429, 502, 503 and 504, and back off between attempts. Do not retry 401, 402 or 404. They will not succeed without a change on your side.