Краткий вывод
- 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.
- Official public pricing is roughly $0.22 / $0.50 / $1.30 per image for 1K / 2K / 4K; ToAPIs currently shows $0.015 / $0.020 / $0.025 per image on the landing comparison, with final billing based on account pricing.
- At the ToAPIs 1K listed rate of $0.015 per image, a $10 top-up is roughly 600+ additional 1K images; at the 4K listed rate of $0.025 per image, it is roughly 400 4K images.
Ключевые параметры
- 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 | опц. | 1:1 | 1K: 1:1 | 3:2 | 2:3; 2K: 1:1 | 3:2 | 2:3 | 4:3 | 3:4 | 5:4 | 4:5 | 16:9 | 9:16 | 2:1 | 1:2 | 21:9 | 9:21; 4K: 16:9 | 9:16 | 2:1 | 1:2 | 21:9 | 9:21 | Output aspect ratio; supported values depend on the selected resolution tier.
- resolution | string | опц. | 1K | 1K | 2K | 4K | Output resolution tier; must match a supported size combination.
- 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 ToAPIs 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.
