Skip to main content

HTTP Status Codes

Status CodeDescriptionCommon Causes
200SuccessRequest processed successfully
400Bad RequestInvalid parameters, missing required fields, malformed JSON
401UnauthorizedInvalid or missing API key
402Payment RequiredInsufficient account balance
403ForbiddenAPI key lacks required permissions
404Not FoundInvalid endpoint URL or task ID not found
429Too Many RequestsRate limit exceeded
500Internal Server ErrorServer-side error, please retry later

Error Response Format

All error responses follow this format:
{
  "error": {
    "message": "Description of the error",
    "type": "error_type",
    "code": "specific_error_code"
  }
}

Error Types

Error TypeDescription
invalid_request_errorThe request was malformed or missing required parameters
authentication_errorAPI key is invalid, expired, or missing
permission_errorThe API key does not have permission for this operation
not_found_errorThe requested resource was not found
rate_limit_errorToo many requests in a given time period
server_errorAn unexpected error occurred on the server

Task-Specific Error Codes

When querying task status, the following error codes may appear in the error.code field:
Error CodeDescriptionRecommended Action
model_unavailableThe requested model is temporarily unavailableRetry after a short delay
content_policy_violationThe input content violates content policiesModify the prompt and retry
generation_failedThe generation process failedRetry the request
timeoutThe task timed outRetry with simpler parameters
invalid_image_urlThe provided image URL is inaccessibleCheck URL accessibility
file_too_largeThe uploaded file exceeds size limitsReduce file size
unsupported_formatThe file format is not supportedUse a supported format

Rate Limits

  • Rate limits are applied per API key
  • When rate limited, wait for the period indicated in the Retry-After header
  • Contact support if you need higher rate limits

Best Practices

  1. Always check the HTTP status code before parsing the response body
  2. Implement exponential backoff for retries on 429 and 500 errors
  3. Log error responses for debugging purposes
  4. Use the task query endpoint to check task status instead of polling too frequently
  5. Handle timeouts gracefully - generation tasks may take varying amounts of time