Skip to main content
Send the key as Authorization: Bearer sk-.... Confirm the key is active in Console > API Keys and that your client is not sending an old key from a different environment variable.
Call GET /v1/models with the same key and copy an exact returned ID. A model can be absent because it has no live route, is disabled, or is outside the key’s model allowlist (which returns api_key_model_not_allowed).
GPT Image 2 and GPT Image 2.5 Ext wait up to 180 seconds by default, then returns HTTP 202 with a gateway task if the job is still running. Set a client timeout longer than 180 seconds, or send Prefer: respond-async and poll GET /v1/tasks/{id}. Do not automatically resubmit after an ambiguous timeout until you have checked that task or the Console logs.
Video generation is asynchronous. Save the returned task ID, poll every 10 to 20 seconds, and download only after the status becomes completed.
Retry 429 and temporary 5xx responses with exponential backoff and jitter. Do not retry invalid parameters, a rejected key, an unavailable model, or insufficient balance without fixing the cause.
Include the same exact model ID as ?model=... in both status and content URLs. Store the model ID together with every task ID.