Skip to content

Key Quota

GET https://api.bve.me/admin/api-keys/:id/quota
Authorization: Bearer admin_bve_YOUR_ADMIN_KEY

Returns the live quota status for a single API key — current request counts for each rate-limit window (minute, day, month), remaining headroom, and when each window resets. Counts come directly from the Durable Object (minute/day/month requests) and D1 (monthly tokens), so values are accurate to within a few seconds.

Admin Bearer token required. See Admin API Overview for authentication details.

ParameterDescription
idThe API key ID (UUID returned when the key was created)
HTTP/1.1 200 OK
Content-Type: application/json
{
"key_id": "01924d3f-1a2b-7c3d-8e4f-5a6b7c8d9e0f",
"status": "active",
"limits": {
"rpm": 60,
"rpd": 1000,
"monthly_requests": 50000,
"monthly_tokens": 10000000
},
"current": {
"minute": {
"count": 5,
"remaining": 55,
"reset_at": "2026-05-23T14:32:00.000Z",
"reset_in_seconds": 47
},
"day": {
"count": 312,
"remaining": 688,
"reset_at": "2026-05-24T00:00:00.000Z",
"reset_in_seconds": 34547
},
"month": {
"request_count": 14820,
"request_remaining": 35180,
"token_count": 2841093,
"token_remaining": 7158907,
"reset_at": "2026-06-01T00:00:00.000Z"
}
},
"checked_at": "2026-05-23T14:31:13.000Z"
}
FieldTypeDescription
key_idstringUUID of the API key
statusstringKey lifecycle status: active, suspended, or revoked
limits.rpmintegerRequests-per-minute cap for this key
limits.rpdintegerRequests-per-day cap for this key
limits.monthly_requestsinteger | nullMonthly request cap, or null if uncapped
limits.monthly_tokensinteger | nullMonthly token cap, or null if uncapped
current.minute.countintegerRequests made in the current minute window
current.minute.remainingintegerRequests remaining before the minute cap is hit
current.minute.reset_atISO 8601When the current minute window resets
current.minute.reset_in_secondsintegerSeconds until the minute window resets
current.day.countintegerRequests made since midnight UTC
current.day.remainingintegerRequests remaining in the current day
current.day.reset_atISO 8601When the current day window resets (midnight UTC)
current.day.reset_in_secondsintegerSeconds until the day window resets
current.month.request_countintegerRequests recorded in D1 for the current calendar month
current.month.request_remaininginteger | nullRequests remaining in the month, or null if uncapped
current.month.token_countintegerTokens recorded in D1 for the current calendar month
current.month.token_remaininginteger | nullTokens remaining in the month, or null if uncapped
current.month.reset_atISO 8601When the monthly window resets (first of next month, UTC)
checked_atISO 8601Timestamp of when this response was generated
Terminal window
curl https://api.bve.me/admin/api-keys/01924d3f-1a2b-7c3d-8e4f-5a6b7c8d9e0f/quota \
-H "Authorization: Bearer admin_bve_YOUR_ADMIN_KEY"
StatusCodeCause
401missing_api_keyNo Authorization header
401invalid_api_keyAdmin key does not match the configured ADMIN_API_KEY secret
404not_foundNo API key exists with the given ID

Check if a key is approaching its limit before a batch job:

Terminal window
QUOTA=$(curl -s https://api.bve.me/admin/api-keys/$KEY_ID/quota \
-H "Authorization: Bearer $ADMIN_KEY")
REMAINING=$(echo "$QUOTA" | jq '.current.minute.remaining')
echo "Remaining this minute: $REMAINING"

Monitor a key’s monthly token burn rate:

import OpenAI from "openai";
const res = await fetch(`https://api.bve.me/admin/api-keys/${keyId}/quota`, {
headers: { Authorization: `Bearer ${adminKey}` },
});
const quota = await res.json();
const tokenPct = quota.current.month.token_count / quota.limits.monthly_tokens;
console.log(`${(tokenPct * 100).toFixed(1)}% of monthly token budget used`);

POST https://api.bve.me/admin/api-keys/:id/reset-quota
Authorization: Bearer admin_bve_YOUR_ADMIN_KEY

Resets the Durable Object request counters for one or all rate-limit windows of a specific API key. Useful when a key has hit its limit due to a runaway process and you need to unblock it immediately, or during testing to reset state between runs.

Optional JSON body. If the body is absent or window is not specified, all three windows are reset.

{
"window": "all"
}
FieldTypeRequiredDescription
windowstringNoWhich window to reset: "minute", "day", "month", or "all" (default)
HTTP/1.1 200 OK
Content-Type: application/json
{
"key_id": "01924d3f-1a2b-7c3d-8e4f-5a6b7c8d9e0f",
"window": "all",
"reset": true
}

Reset all windows (default):

Terminal window
curl -X POST https://api.bve.me/admin/api-keys/01924d3f-1a2b-7c3d-8e4f-5a6b7c8d9e0f/reset-quota \
-H "Authorization: Bearer admin_bve_YOUR_ADMIN_KEY"

Reset only the per-minute window:

Terminal window
curl -X POST https://api.bve.me/admin/api-keys/01924d3f-1a2b-7c3d-8e4f-5a6b7c8d9e0f/reset-quota \
-H "Authorization: Bearer admin_bve_YOUR_ADMIN_KEY" \
-H "Content-Type: application/json" \
-d '{"window": "minute"}'
StatusCodeCause
400validation_errorwindow is not one of "minute", "day", "month", "all"
404not_foundNo API key exists with the given ID