GPT Image 2 API-Dokumente
GPT Image 2 API-Dokumente
GPT Image 2 APIQuickstartAuthenticationPricing
Polling strategyCredits & modelsErrors & refunds
Guides

Errors & refunds

HTTP status codes returned by the API, error shape, and the automatic refund contract.

Status codes

CodeMeaningRetryable
200Request accepted or task snapshot returned—
400Request body failed validation — inspect details for field-level errorsNo (fix the payload)
401Missing or invalid credentialsNo (check key)
402Insufficient credits — no charge was madeNo (top up)
404Task not found, or owned by a different callerNo
500Unexpected server errorYes, with backoff

Error shape

All errors return JSON with an error field. Some include additional keys.

400 Bad Request
{
  "error": "Invalid request",
  "details": {
    "formErrors": [],
    "fieldErrors": {
      "prompt": ["Prompt is required"]
    }
  }
}
402 Payment Required
{
  "error": "Insufficient credits",
  "required": 12
}
401 Unauthorized
{ "error": "Unauthorized" }

Automatic refunds

Credits are pre-debited at submission time. If the task ends in status: 2 (FAILED) — for any reason, including provider timeouts and storage errors — credits are refunded atomically via a creditRefunded flag on the task row. You do not need to request the refund.

The refunded amount equals creditsUsed from the submission response. Check creditsRefunded: true in the GET /api/ai/tasks/{id} response to confirm.

Common failure modes

  • EMPTY_RESULT — the upstream provider reported success but returned no output URL. Auto-refund applies.
  • STORAGE_ERROR — we could not persist the upstream output to our CDN. Auto-refund applies.
  • Provider-specific codes — passed through from the upstream model. Auto-refund applies.

Idempotency

Endpoints are not yet idempotent. If a POST /generate call times out from the client side, check for any recent tasks belonging to your account via the dashboard before retrying, to avoid double-charging.

Credits & models

How credits are debited and refunded, plus the full list of supported models.

Inhaltsverzeichnis

Status codesError shapeAutomatic refundsCommon failure modesIdempotency