Learn about common API errors, their causes, and how to resolve them. Use this guide to debug issues and implement robust error handling in your applications.
| Status | Name | Severity | One-line description |
|---|---|---|---|
| 200 | OK | Info | Request succeeded and response is ready. |
| 401 | Unauthorized | Error | Missing, invalid, or expired API key. |
| 402 | Payment Required | Error | Insufficient credits to complete the request. |
| 403 | Forbidden | Warning | Authenticated but insufficient permissions. |
| 404 | Not Found | Warning | Model not found or incorrect API path. |
| 422 | Unprocessable Entity | Warning | Validation failed — missing or invalid fields. |
| 429 | Too Many Requests | Error | Rate limit exceeded, wait for retry_after seconds. |
| 500 | Internal Server Error | Critical | Unexpected server error, retry with backoff. |
When the LLM Resayil API encounters an error, it returns a JSON response describing what went wrong. Understanding how to parse these responses is essential for building robust error handling in your applications.
All error responses follow this unified format:
{
"error": {
"message": "Human-readable error message",
"code": 401
}
}
Certain errors — such as validation errors (422) — include an additional errors
object with per-field validation details:
{
"error": {
"message": "Validation failed",
"code": 422
},
"errors": {
"model": ["The model field is required."],
"messages": ["The messages field must be an array."]
}
}
Missing or invalid API key in the Authorization header.
HTTP/1.1 401 Unauthorized
{
"error": {
"message": "Unauthenticated.",
"code": 401
}
}
Authorization: Bearer YOUR_KEYYour credit balance has been exhausted. You must top up to continue making API calls.
HTTP/1.1 402 Payment Required
{
"error": {
"message": "Insufficient credits. Please top up your balance to continue.",
"code": 402
}
}
GET /api/billing/subscription endpointAuthenticated but the account does not have sufficient permissions to access the requested resource.
HTTP/1.1 403 Forbidden
{
"error": {
"message": "You do not have permission to access this resource.",
"code": 403
}
}
The requested model does not exist, or the API path is incorrect.
HTTP/1.1 404 Not Found
{
"error": {
"message": "Model not found.",
"code": 404
}
}
model field of your requestRequest validation failed. The response includes an errors object describing each invalid field.
HTTP/1.1 422 Unprocessable Entity
{
"error": {
"message": "Validation failed",
"code": 422
},
"errors": {
"model": ["The model field is required."],
"messages": ["The messages field must be an array."]
}
}
errors object to identify the problematic fieldsmodel and messagesmessages is an array of objects with role and content
You have exceeded your rate limit. The response includes a retry_after field
indicating how many seconds to wait before retrying.
HTTP/1.1 429 Too Many Requests
X-RateLimit-Limit: 20
X-RateLimit-Remaining: 0
X-RateLimit-Reset: 1741305600
{
"error": {
"message": "Rate limit exceeded",
"code": 429
},
"retry_after": 45
}
retry_after before retryingAn unexpected server-side error occurred. These are rare and usually temporary.
HTTP/1.1 500 Internal Server Error
{
"error": {
"message": "An unexpected error occurred. Please try again later.",
"code": 500
}
}
When you encounter an error, work through this checklist to identify and resolve the issue:
application/jsonX-RateLimit-Remaining header in your responsesDo not just check the HTTP status code. Parse the error response JSON to understand what went wrong and provide meaningful feedback to your users.
Use exponential backoff with jitter for retryable errors (429, 500). See the Rate Limits guide for implementation details.
Log full error responses including status codes, error codes, and request IDs. This makes debugging significantly faster.
Do not expose raw error messages to users. Map error codes to friendly messages and provide actionable guidance.
Check X-RateLimit-Remaining in responses and throttle requests before hitting
the limit.
Set request timeouts to at least 30 seconds to allow for slower models and network latency.