Error Codes
Relai uses standard HTTP status codes and returns detailed error information in the response body.
Error Response Format
{
"error": {
"message": "Human-readable error description",
"type": "error_type",
"code": "specific_error_code",
"param": "field_name"
}
}HTTP Status Codes
| Status | Meaning |
|---|---|
| 400 | Bad Request — Invalid parameters |
| 401 | Unauthorized — Invalid or missing API key |
| 403 | Forbidden — Key doesn't have access to this resource |
| 404 | Not Found — Resource doesn't exist |
| 429 | Too Many Requests — Rate limit exceeded |
| 500 | Internal Error — Something went wrong on our end |
| 502 | Bad Gateway — Upstream provider error |
| 503 | Service Unavailable — Temporary overload |
Common Error Types
Authentication Errors (401)
{
"error": {
"message": "Invalid API key provided",
"type": "invalid_api_key"
}
}Solutions:
- Check your API key starts with
rk-eu-orrk-us- - Verify the key hasn't been revoked
- Ensure the
Authorizationheader format isBearer YOUR_KEY
Rate Limit Errors (429)
{
"error": {
"message": "Rate limit exceeded: 60 requests per minute",
"type": "rate_limit_exceeded",
"retry_after": 12
}
}Solutions:
- Wait for the
retry_afterseconds - Implement exponential backoff
- Increase your key's RPM limit in the dashboard
Insufficient Balance (402)
{
"error": {
"message": "Insufficient credit balance",
"type": "insufficient_balance",
"balance_micro": 0,
"required_micro": 150000
}
}Solutions:
- Add credits in the dashboard billing page
- Enable auto-recharge to prevent interruptions
Region Mismatch (403)
{
"error": {
"message": "API key is for region EU, but request was made to US",
"type": "region_mismatch"
}
}Solutions:
- Use
eu.api.llmrelai.comwithrk-eu-keys - Use
us.api.llmrelai.comwithrk-us-keys
Retry Strategy
For transient errors (429, 502, 503), implement exponential backoff:
async function callWithRetry(fn, maxRetries = 3) {
for (let i = 0; i < maxRetries; i++) {
try {
return await fn();
} catch (error) {
if (i === maxRetries - 1) throw error;
const status = error.status;
if (![429, 502, 503].includes(status)) throw error;
const delay = Math.min(1000 * Math.pow(2, i), 30000);
await new Promise(r => setTimeout(r, delay));
}
}
}Getting Help
If you encounter persistent errors:
- Check our status page
- Contact support at support@llmrelai.com
- Include the
X-Request-Idheader from the response