What Is the gpt-image-2 API?
The gpt-image-2 API is a REST surface that turns a prompt (and up to four reference images) into a production-ready PNG. You POST to /api/v1/images/generate with a Bearer token, receive a task_id, and poll /api/v1/images/task/[id] until the image is ready. Every response is JSON — success envelope on 2xx, error envelope with a stable code and request_id on 4xx and 5xx. Each render is stored on our R2 CDN and served over HTTPS, so you can hotlink the URL or mirror it to your own bucket. Credits are deducted atomically at submit time and refunded automatically when a task fails, so your billing never drifts from your actual output. The surface is user-scoped: keys inherit the owning account's credit balance and can only see tasks created programmatically, not tasks from the web studio. Everything you send is JSON — no multipart uploads, no SDK lock-in, no hidden retries.