HTTP status codes and error response format
Error Response Format
All errors return a JSON body in the following format:
{
"error": {
"message": "A human-readable error description",
"type": "error_type",
"code": "error_code"
}
}
HTTP Status Codes
| Status | Meaning |
|---|---|
200 | Success |
400 | Bad Request — invalid parameters or request body |
401 | Unauthorized — missing or invalid API key |
403 | Forbidden — insufficient permissions |
404 | Not Found — resource or endpoint does not exist |
429 | Too Many Requests — rate limit exceeded or insufficient quota |
500 | Internal Server Error — server or upstream error |
503 | Service Unavailable — upstream service unavailable |
Common Error Codes
| Code | HTTP Status | Description |
|---|---|---|
invalid_request_body | 400 | Request body could not be parsed, check JSON format |
invalid_request | 400 | Parameter validation failed |
invalid_api_key | 401 | API key is missing or invalid |
insufficient_quota | 429 | Account quota exhausted |
upstream_error | 500 | Upstream provider returned an error |
unmarshal_response_body_failed | 500 | Failed to parse upstream response |
Async Task Status
For async tasks (video, image generation tasks), the task status field uses:
| Status | Description |
|---|---|
IN_PROGRESS | Task is being processed, poll again later |
SUCCESS | Task completed, result URL is available |
FAILURE | Task failed, check the reason field |
Rate Limiting
When the rate limit is exceeded, the response will include:
{
"error": {
"message": "Rate limit exceeded. Please try again later.",
"type": "requests",
"code": "rate_limit_exceeded"
}
}
Note Implement exponential backoff when handling
429errors to avoid repeated failures.