API basics

API Error Codes

ZroImg API error format and codes: auth failures, insufficient credits, rate and concurrency limits, idempotency conflicts, invalid params, not found, and retries.

On this page

Error format

When a request fails, the API returns a 4xx or 5xx status code with this response body:

json
{
  "error": {
    "code": "invalid_request",
    "message": "Model gpt-image-2 does not support ratio 21:9",
    "type": "invalid_request_error"
  }
}
FieldDescription
codeStable error code; your program should use it to determine the error type
messageHuman-readable description (currently in Chinese); its content may change, so don't rely on it in program logic
typeError category: invalid_request_error, authentication_error, rate_limit_error or api_error

Error code list

HTTP statuscodeMeaningRecommended handling
400invalid_requestParameters missing or malformed, unsupported mode/ratio/quality, or a reference image failed to download or its URL is unsafeFix the parameters based on message; don't retry as-is
401invalid_api_keyKey missing, incorrect, expired or revoked, or the account is disabledCheck the Authorization header and create a new key if needed
402insufficient_pointsInsufficient credits; no task was created and nothing was chargedRetry after you buy credits
403invalid_signatureResult download link has an invalid or expired signatureCall GET /tasks/{id} again to get a new link
404model_not_foundModel does not exist, is disabled, or its type doesn't match the endpointCall the models list again
404task_not_foundTask does not exist or does not belong to your accountCheck the task ID
404file_not_foundThe result file has been deletedIt cannot be recovered; generate it again
409idempotency_conflictA request with the same Idempotency-Key is still being processedWait a few seconds and retry with the same value
429rate_limitedPer-minute request limit exceededWait for the duration in the Retry-After response header, then retry
429concurrency_limitIn-progress task cap reachedWait for the Retry-After duration (10 seconds), or until existing tasks finish, before submitting
500server_errorInternal server errorRetry later; for submit endpoints, reuse the same Idempotency-Key
502upstream_errorUpstream service failure (e.g. prompt polish failed; credits have been refunded)Retry later

Retry strategy

  • Retry: 409, 429, 500, 502 and network timeouts. Use exponential backoff (e.g. 2, 4, 8 seconds); for 429, prefer Retry-After.
  • Don't retry: 400, 401, 402, 403, 404; fix the request first.
  • Reuse the same `Idempotency-Key` when retrying submit endpoints, so that even if the first request actually succeeded, no second task is created and you aren't charged twice. See Idempotent submission.

Task failures vs. API errors

A 202 from a submit endpoint only means the task has been created. Problems that occur during generation are not returned as HTTP errors; instead they are reflected on the task: GET /tasks/{id} returns status: "failed" and error.message. Credits for failed tasks are refunded automatically.