Краткий вывод
- Use POST /v1/images/generations with model=gpt-image-2.
- Supports prompt generation and reference_images URL inputs for guided generation.
- Reference images must be URLs, so local files must be uploaded first instead of passing base64 directly.
- The endpoint returns an async task id for later status polling.
Ключевые параметры
- model | string | обяз. | gpt-image-2 | - | Use gpt-image-2 as the exact model id.
- prompt | string | обяз. | - | - | Primary prompt for image generation or editing.
- size | string | опц. | 1024x1024 | Use documented combinations with resolution | Output size constrained by documented resolution combinations.
- resolution | string | опц. | 1024 | 1024 | 1536 | 2048 | Output resolution with documented size constraints.
- reference_images | string[] | опц. | - | URL array | Reference image URL array. Local files must be uploaded first; no direct base64 references.
- image_urls | string[] | опц. | - | URL array (compat field) | Compatibility field; prefer reference_images for new integrations.
- response_format | string | опц. | url | url | b64_json | Response format; current Chinese docs recommend url.
Частые ошибки
- 400 invalid_request_error: триггер=Missing required fields or invalid size-resolution combinations.; исправление=Validate model, prompt, size, resolution, and response_format against docs.; повтор=Retry only after correcting the payload.
- 400 invalid_reference_images: триггер=Passing base64, local paths, or non-URL reference_images values.; исправление=Upload the image first and pass the resulting URL in reference_images.; повтор=Retry after fixing the reference image input.
- 401 authentication_error: триггер=Missing Authorization header or invalid API key.; исправление=Verify bearer token format and key scope.; повтор=Retry after fixing authentication.
- 429 rate_limit_exceeded: триггер=Request rate, concurrency, or current quota hits upstream rate limiting.; исправление=Apply exponential backoff first, then review request rate, concurrency, and quota usage.; повтор=Use 1s/2s/4s backoff with jitter; if it persists, reduce submission pressure.


