AI Gateway Rate Limits
AI Gateway does not rate limit paid-tier requests. The free tier applies lower per-model limits, and a 429 on either tier may come from the upstream provider rather than from AI Gateway.
On the free tier, AI Gateway enforces a lower limit per model, and exceeding it rejects further requests to that model until your request rate drops. The paid tier removes AI Gateway's limits entirely, so the only limits left are the upstream provider's, whether the request uses AI Gateway credentials or your own provider keys.
Whether a 429 comes from AI Gateway or the provider, the retry behavior below is the same. A provider's 429 can carry that provider's own error body instead of the AI Gateway error shape.
Limits can change, so this page describes behavior rather than fixed numbers. To confirm the current limit for a model, contact Vercel from your dashboard's Support entry.
| Free tier | Paid tier | |
|---|---|---|
| Model access | Free-tier-eligible models | All available models |
| Rate limits | Lower limit per model | None from AI Gateway; provider limits still apply |
| Custom limits | Not available | Available on request |
| Credit basis | Monthly included credit | Purchased AI Gateway Credits |
Purchasing AI Gateway Credits moves your team to the paid tier, which raises your rate limits. See AI Gateway Pricing for tiers, credits, and model rates.
A rate-limited request gets an HTTP 429 response. From AI Gateway, the body is a JSON error:
{
"error": {
"message": "Rate limit exceeded",
"type": "rate_limit_exceeded"
}
}Some 429 responses include a retry-after header with the number of seconds to wait. Honor it when it is present.
A 429 response is not a failure of your request. The same request can succeed later without changes, so retry it rather than editing it.
The AI SDK retries failed requests automatically with exponential backoff, and its maxRetries option defaults to 2. For a direct HTTP client, honor retry-after when it is present and parseable, and back off exponentially otherwise:
// `retry-after` is either a number of seconds or an HTTP date. Anything that
// doesn't parse falls through to exponential backoff, so a malformed header
// can't collapse the wait to zero and turn the loop into a burst of requests.
function retryAfterMs(header: string | null): number | null {
if (!header) return null;
const seconds = Number(header);
if (Number.isFinite(seconds) && seconds >= 0) return seconds * 1000;
const date = Date.parse(header);
if (Number.isNaN(date)) return null;
return Math.max(0, date - Date.now());
}
async function chatWithRetry(body: string, maxAttempts = 4): Promise<Response> {
for (let attempt = 0; attempt < maxAttempts; attempt++) {
const response = await fetch(
'https://ai-gateway.vercel.sh/v1/chat/completions',
{
method: 'POST',
headers: {
Authorization: `Bearer ${process.env.AI_GATEWAY_API_KEY}`,
'Content-Type': 'application/json',
},
body,
},
);
if (response.status !== 429) {
return response;
}
// Don't sleep after the final attempt.
if (attempt === maxAttempts - 1) break;
const delayMs =
retryAfterMs(response.headers.get('retry-after')) ?? 2 ** attempt * 1000;
await new Promise((resolve) => setTimeout(resolve, delayMs));
}
throw new Error('Request still rate limited after all retries');
}Keep retries bounded. If a workload hits a limit regularly, raise the limit instead of lengthening the backoff.
Rate limits and budgets both reject requests, but for different reasons:
| Rate limit | Budget | |
|---|---|---|
| What it caps | Request rate for a model | Spend in dollars |
| Who sets it | Vercel, per tier | You, per team, project, API key, or user |
| Response when hit | 429 | 402 with quota_for_entity_exceeded |
| Recovery | Retry after a short wait | Wait for the refresh period or raise the limit |
To cap spend instead of request rate, set a budget.
BYOK requests use your own provider credentials, so the provider's own rate limits apply to them. When a BYOK request fails and falls back to AI Gateway system credentials, the fallback attempt is subject to AI Gateway rate limits, and its usage is billed to your AI Gateway Credits.
Purchase AI Gateway Credits to move your team to the paid tier, which removes AI Gateway's rate limits. If a provider-side limit still constrains a workload, paid-tier teams can request custom arrangements. Contact sales to discuss custom limits.
- AI Gateway Pricing for tiers, credits, and model rates
- Budgets to cap spend by team, project, API key, or team member
- Troubleshoot request errors by status code, type, and message
Was this helpful?