Errors and limits
Errors use the OpenAI error shape, so existing SDK error handling keeps working. Failed requests never charge your balance.
Error format
{
"error": {
"message": "Insufficient balance. Deposit CEREBRA to top up your API balance.",
"type": "insufficient_quota",
"code": "insufficient_balance",
"balance": "0.000000"
}
}Match on error.code in code. error.message is for people and may change.
Status and error codes
| Status | Code | Type | Meaning |
|---|---|---|---|
| 400 | invalid_request | invalid_request_error | Body is not valid JSON or is missing model or messages. |
| 400 | invalid_max_cost | invalid_request_error | max_cost is not a non-negative decimal amount in USD. |
| 400 | invalid_address / invalid_epoch | invalid_request_error | Malformed address or epoch in a key or account request. |
| 401 | invalid_api_key | authentication_error | Key missing, unknown, or revoked by a newer epoch. |
| 401 | invalid_signature | authentication_error | The signature does not match the address and message. |
| 402 | insufficient_balance | insufficient_quota | Balance cannot cover even one output token. The body includes balance. |
| 402 | max_cost_exceeded | insufficient_quota | max_cost is too low to cover this prompt. |
| 404 | model_not_found | not_found_error | Unknown model id. List models with GET /v1/models. |
| 409 | epoch_revoked | invalid_request_error | That epoch was revoked. The current epoch is in the message. |
| 429 | upstream_error | rate_limit_error | The provider is rate limiting. Retry with backoff. |
| 499 | client_closed | invalid_request_error | The client closed the connection before the response. |
| 502 | upstream_error / upstream_unreachable | api_error | The provider failed or is unreachable. Nothing is charged. |
| 503 | provider_unavailable | api_error | The model's provider is not configured on this gateway. |
Handling errors
from openai import OpenAI, APIStatusError
try:
client.chat.completions.create(model="deepseek/deepseek-flash", messages=msgs)
except APIStatusError as e:
code = e.body.get("code") if isinstance(e.body, dict) else None
if code == "insufficient_balance":
print("Top up your balance")
elif e.status_code in (429, 502):
pass # retry with exponential backoffRate limits
The edge allows an average of 20 requests per second per IP address with bursts of up to 40. Requests over the limit receive 429 Too Many Requests without a JSON body. There is no per-key token limit: throughput is bounded by your balance and by the provider.
| Limit | Value | Notes |
|---|---|---|
| Requests per IP | 20 per second, burst 40 | Enforced at the edge. |
| Output tokens per request | Model maximum | Defaults to 8,192 when max_tokens is not set. |
| Spend per request | Your balance, or max_cost | Whichever is lower. |
Retry guidance
Retry 429 and 5xx responses with exponential backoff and jitter. Do not retry 4xx errors other than 429.