Quotas and rate limits
The gateway checks each request against your credit balance, any configured token budget and the request-rate limits. Streams also count against a per-key concurrency limit. This page lists the defaults, the error each check returns and the headers that report what is left.
Credit balance (402)
Billing is prepaid, so every request checks your credit balance first. When the balance is at or below zero, and past any configured grace window, requests get 402 Payment Required:
{ "error": { "type": "billing_error", "code": "insufficient_balance", "message": "Insufficient credit balance. Please top up your account to continue.", "action": "topup", "top_up_url": "https://app.cloakapi.io/billing" }}Top up in the portal under Billing.
Token quotas (429)
Separately from the balance, the gateway can enforce hourly and daily token budgets per configured segment. The default configuration enables none. When a segment budget is configured, a request over it gets 429 with a Retry-After header and one of two codes:
{ "error": { "type": "rate_limit_error", "code": "hourly_quota_exceeded", "message": "Hourly token quota exceeded. Retry after the top of the hour.", "quota": { "window": "hourly", "limit": 1000000, "used": 1000000 } }}daily_quota_exceeded is the daily equivalent. Successful responses carry X-CloakAPI-Quota-Hourly-Remaining and X-CloakAPI-Quota-Daily-Remaining only when at least one token budget is configured, so treat a missing header as “no token budget configured”, not as zero. Requests routed to local Ollama are not charged or quota-blocked.
Request rate limits
The gateway counts authenticated API-key requests in fixed 60-second windows. It checks three buckets and rejects a request when any of them is over its limit:
| Bucket | Default | Notes |
|---|---|---|
| Per API key | 60 req/min (self-service keys: 20) | Stored on the key; can be set up to 600 req/min |
| Per organization | 600 req/min | Shared by every key the organization holds, so issuing more keys does not add quota |
Per source IP (/64 for IPv6) | 300 req/min | Shared egress cannot rotate keys past the organization ceiling |
Responses carry X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset and X-RateLimit-Scope, describing the tightest bucket. Verifying your email address does not raise a key’s limit. Public endpoints have their own per-IP limits: 30 req/min for /api/v1/receipts/verify and 120 req/min for /.well-known/* discovery.
Authentication, DSAR, and public intake limits
These API routes have their own limits. For API requests, a rejected throttle request returns HTTP 429 as JSON with error.code set to too_many_attempts, error.retry_after_s, and a Retry-After header. The route’s tightest bucket decides when it can be retried.
| Route group | Limit |
|---|---|
Signup (/api/auth/register, /api/v1/consumer-auth/password/signup) | 20/min per IP or IPv6 /64, and 5/min per email key |
Login (/api/auth/login, /api/v1/consumer-auth/password/login) | 30/min per IP or IPv6 /64, and 10/min per email key |
Consumer magic-link request (/api/v1/consumer-auth/magic-link/request) | 15/min per IP or IPv6 /64, and 3/min per email key |
Password recovery (/api/auth/forgot-password, /api/auth/reset-password) | 5/min and 10/min per route, respectively |
DSAR (/api/gdpr/*, /api/v1/erasure-receipts/*) | 10/min per route |
Self-service key issuance (/api/v1/self-service/key) | 5/hour and 20/day per IP or IPv6 /64 |
Public receipt verification (/api/v1/receipts/verify) | 30/min per route |
Public intake: /api/v1/campaigns/intent, /api/early-access, /api/v1/signedreceipts/submit, /api/v1/changelog/* | 6/min, 10/min, 10/min, and 5/min per route, respectively |
These figures describe the listed routes; other routes can have different limits.
Streams and high-volume workloads
There is no general cap on concurrent connections, but each API key can run 5 concurrent streams by default. The gateway checks the limit before the SSE response starts, so a stream over the limit gets HTTP 429 stream_concurrency_limit with Retry-After. Retry after one of your streams finishes.
There is no array or batch request endpoint. A high-volume pipeline fans out parallel requests under the rate limits and uses Idempotency-Key for safe retries. Sustained volume is bounded by the per-minute limits above and, when configured, by the token quotas.
Higher limits are provisioned, not self-serve. A key’s ceiling is stored on the key and can be raised per tenant. If a batch or data pipeline needs sustained volume above 600 req/min, email support@cloakapi.io with your target sustained requests per minute and daily token volume, and we set production limits so we can line up matching upstream provider capacity. Production limits are agreed per account, so ask for them rather than assuming the defaults above are your cap.
Error codes
These stable codes are returned on the documented chat-completion request path. Other API routes can return route-specific validation and account errors.
| Code | HTTP | Meaning |
|---|---|---|
insufficient_balance | 402 | The prepaid balance cannot cover the request. Add credit to continue. |
hourly_quota_exceeded | 429 | The configured hourly token budget is exhausted; retry after the hour rolls over. |
daily_quota_exceeded | 429 | The configured daily token budget is exhausted; retry after the daily window. |
rate_limit_exceeded | 429 | A request-rate bucket is exhausted; use Retry-After before retrying. |
model_not_priced | 400 | The requested chat model ID has no configured price. Choose suggested_model when the response includes it, or select an ID from GET /api/v1/models. |
model_unknown_refresh_catalogue | 409 | The model is priced but missing from the current chat catalog. Refresh the model list and choose suggested_model when included. |
model_retired / model_unavailable | 400 | The requested chat model is no longer available. Choose suggested_model when the response includes it. |
stream_concurrency_limit | 429 before SSE | The per-key concurrent stream limit is reached. The gateway claims a slot before opening the upstream stream; if the atomic claim exceeds the limit, it returns HTTP 429 with Retry-After before the SSE response starts. Retry after a stream finishes. |
idempotency_key_conflict | 409 | The same idempotency key was used with a different request body. |
idempotency_response_not_retained | 409 | The request already completed; its response is not retained for replay. |
idempotency_request_in_progress | 409 | A request with this key is still running; retry later with the same key. |
Model-selection errors include error.suggested_model when a current alternative is available; the value can be null when there is no recommendation.
Idempotency
Send Idempotency-Key: <uuid> with a POST request. The gateway remembers the key for 24 hours. The 24-hour window and the debit retry generation both use the database clock, so application-server clock skew does not move the window boundary.
On the model endpoints (chat/completions, messages, embeddings), the gateway keeps a SHA-256 idempotency digest derived from the request, and a completion marker. After a successful completion, a retry with the same key and body is refused with 409 idempotency_response_not_retained and does not consume quota. The response is not replayed, so keep the original response and its receipt.
Key, billing and account endpoints that return no secret can replay their cached response. API-key mint and rotation return one-time secrets, so they keep only a SHA-256 request-body digest and a completion marker: a retry with the same key and body returns 409 idempotency_response_not_retained and does not replay the secret.
Use this pattern when your code controls the HTTP request and can send the same key with each retry. The current SDK relay clients do not expose a general Idempotency-Key option: they send each reviewed relay POST once, so this header does not enable SDK-managed relay retries.
Organization invitations
POST /api/v1/organisation/invitations allows 150 invitations per organization in a rolling 24-hour window. The next one returns 429 with error set to invite_limit_reached. Resending an invitation that is still pending does not count as a new one.
GET and PATCH /api/v1/organisation/me, and accepting an invitation, do not return seat_limit.