Skip to content
Docs

Update an AI Gateway API key budget

PATCH/__remote/api.vercel.com/api-keys/{apiKeyID}/quota
Set, change, or remove the AI Gateway budget on an API key. Creates the budget if the key does not have one.
/__remote/api.vercel.com/api-keys/{apiKeyID}/quota
const response = await fetch('/__remote/api.vercel.com/api-keys/apiKeyID/quota', {
method: 'PATCH',
headers: {
'Authorization': 'Bearer YOUR_ACCESS_TOKEN',
'Content-Type': 'application/json',
},
body: JSON.stringify({
"limitAmount": "123",
"includeByokInQuota": "true",
"refreshPeriod": "daily",
"active": "true",
"archived": "true",
"alertThresholds": []
}),
});
const data = await response.json();
console.log(data);
Response
{
"apiKey": {
"id": "5d9f2ebd38ddca62e5d51e9c1704c72530bdc8bfdd41e782a6687c48399e8391",
"name": "API Key for AI Gateway",
"partialKey": "t7V",
"teamId": "team_123a6c5209bc3778245d011443644c8d27dc2c50",
"purpose": "ai-gateway",
"projectId": "prj_12HKQaOmR5t5Uy6vdcQsNIiZgHGB",
"expiresAt": "1632816536002",
"activeAt": "1632816536002",
"createdAt": "1632816536002",
"createdBy": "ZspSRT4ljIEEmMHgoDwKWDei",
"leakedAt": "1632816536002",
"leakedUrl": "https://example.com",
"createdByAppId": "example_id",
"quota": {
"quotaEntityId": "example_id",
"limitAmount": "123",
"currentSpend": "123",
"currentByokSpend": "123",
"includeByokInQuota": "true",
"refreshPeriod": "string",
"active": "true",
"archived": "true",
"alertThresholds": [],
"createdAt": "123",
"updatedAt": "123"
},
"metadata": "value"
},
"quota": {
"quotaEntityId": "example_id",
"limitAmount": "123",
"currentSpend": "123",
"currentByokSpend": "123",
"includeByokInQuota": "true",
"refreshPeriod": "string",
"active": "true",
"archived": "true",
"alertThresholds": [],
"createdAt": "123",
"updatedAt": "123"
}
}
Errors
{
"error": {
"code": "string",
"message": "string"
}
}
AuthorizationbearerToken

Default authentication mechanism

apiKeyIDstringRequired
The ID of the API key whose quota should be updated.
application/json
limitAmountnumberOptional
The quota limit amount. Required if the quota does not yet exist.
includeByokInQuotabooleanOptional
Whether BYOK (Bring Your Own Key) usage counts against the quota.
refreshPeriodstringOptional
How often the quota refreshes.
activebooleanOptional
Whether the quota is currently active.
archivedbooleanOptional
Set to true to archive (soft-delete) the quota. The api key itself is unaffected.
alertThresholdsarrayOptional
Spend percentages (a subset of [50, 75, 100]) at which to send a spend alert. Pass an empty array to disable alerts.
200Successfully updated the API key quota.
apiKeyobjectRequired
Represents an API key.
quotaobjectRequired
AI Gateway quota associated with an API key.
400One of the provided values in the request body is invalid. One of the provided values in the request query is invalid.
401The request is not authorized.
errorobjectRequired
403You do not have permission to access this resource.
errorobjectRequired
404Error
410Error
429Error
errorobjectRequired
500Error
errorobjectRequired