HTTP Status Codes
| Status Code | Description | Common Causes |
|---|---|---|
200 | Success | Request processed successfully |
400 | Bad Request | Invalid parameters, missing required fields, malformed JSON |
401 | Unauthorized | Invalid or missing API key |
402 | Payment Required | Insufficient account balance |
403 | Forbidden | API key lacks required permissions |
404 | Not Found | Invalid endpoint URL or task ID not found |
429 | Too Many Requests | Rate limit exceeded |
500 | Internal Server Error | Server-side error, please retry later |
Error Response Format
All error responses follow this format:Error Types
| Error Type | Description |
|---|---|
invalid_request_error | The request was malformed or missing required parameters |
authentication_error | API key is invalid, expired, or missing |
permission_error | The API key does not have permission for this operation |
not_found_error | The requested resource was not found |
rate_limit_error | Too many requests in a given time period |
server_error | An unexpected error occurred on the server |
Task-Specific Error Codes
When querying task status, the following error codes may appear in theerror.code field:
| Error Code | Description | Recommended Action |
|---|---|---|
model_unavailable | The requested model is temporarily unavailable | Retry after a short delay |
content_policy_violation | The input content violates content policies | Modify the prompt and retry |
generation_failed | The generation process failed | Retry the request |
timeout | The task timed out | Retry with simpler parameters |
invalid_image_url | The provided image URL is inaccessible | Check URL accessibility |
file_too_large | The uploaded file exceeds size limits | Reduce file size |
unsupported_format | The file format is not supported | Use a supported format |
Rate Limits
- Rate limits are applied per API key
- When rate limited, wait for the period indicated in the
Retry-Afterheader - Contact support if you need higher rate limits
Best Practices
- Always check the HTTP status code before parsing the response body
- Implement exponential backoff for retries on 429 and 500 errors
- Log error responses for debugging purposes
- Use the task query endpoint to check task status instead of polling too frequently
- Handle timeouts gracefully - generation tasks may take varying amounts of time