Error Handling
Ruvicode API error codes and error handling. Learn how to retry on rate limits, handle insufficient balance, and parse OpenAI-format error responses.
Ruvicode returns standard HTTP status codes. Error responses follow the OpenAI format.
Error format
{
"error": {
"message": "Human-readable error message",
"type": "error_type"
}
}Common errors
| Status | Type | Meaning | Action |
|---|---|---|---|
| 400 | invalid_request_error | Bad request parameters | Check your request body |
| 400 | content_policy_violation | Image request rejected by the content policy (nothing is charged) | Change the prompt or the input image |
| 401 | authentication_error | Invalid, missing, or revoked API key | Check your Authorization header or key status |
| 402 | insufficient_balance | Wallet balance or spend limit | Top up your wallet or raise the key's spend limit |
| 403 | invalid_request_error | Model not allowed for this key | Add the model to the key's allowed models, or use another key |
| 404 | invalid_request_error | Model not found | The model id does not exist, check the id against /v1/models |
| 429 | rate_limit_error | Rate limit exceeded | Wait and retry, or reduce frequency |
| 500 | api_error | Server error | Retry with backoff |
| 503 | api_error | Model temporarily unavailable | Retry, or switch models |
The 403 vs 404 split is deliberate: 404 means the model id does not exist at all, 403 means it exists but the key you used is not allowed to call it. A scoped-out request never reaches a model, so it costs nothing.
Rate limiting
Rate limiting works in two layers, both a sliding 60-second window. Each key has its own limit (default 100, up to 700), and all keys in your account share one account-wide budget of 700 requests per minute, so creating more keys does not add capacity. When exceeded:
{
"error": {
"message": "Rate limit exceeded. Retry after 60 seconds.",
"type": "rate_limit_error"
}
}When the account-wide budget is the one hit, the message says so explicitly:
{
"error": {
"message": "Account rate limit exceeded. All of your keys share one requests-per-minute budget. Retry after 60 seconds.",
"type": "rate_limit_error"
}
}Response headers include rate limit info:
X-RateLimit-Limit: 100
X-RateLimit-Remaining: 0
Retry-After: 60
Agentic tools bursting many parallel requests should keep the limit in mind, denied requests still count against the window for the next 60 seconds.
Retry strategy
For 429 and 503 errors, use exponential backoff. Image requests take longer (usually 5 to 30 seconds), so give image calls a client timeout of at least 2 minutes:
import time
def retry_with_backoff(fn, max_retries=3):
for attempt in range(max_retries):
try:
return fn()
except Exception as e:
if attempt == max_retries - 1:
raise
time.sleep(2 ** attempt) # 1s, 2s, 4sInsufficient balance
If your wallet runs out mid-session, you'll receive a 402 error. Top up your wallet to resume. Your existing API keys remain valid, no need to regenerate them. Spend limits work the same way: raising or removing the limit on the key in the dashboard takes effect immediately.