Skip to main content
Use the public model ID gpt-image-2 with POST /images/generation. Each new request creates a job for one image. You can generate from a prompt alone or provide up to 16 uploaded reference images.

Create a job

Send an organization API key and a unique Idempotency-Key. Reuse the same key and request body when retrying the same job.
The API responds with HTTP 202 and a job. Read its id and status, then poll the job until it reaches a final status. On success, download the image from output.files. Fetch the job again when you need a fresh signed URL.

Input fields

Unknown fields at the request root or inside input return 400 invalid_parameter. The request supports optional metadata and max_cost_usd fields.

Generate with reference images

Upload each image before submitting the job. Pass its file_id or upload_fields.key in referenceImageKeys. Each reference must belong to your workspace, have an image/* content type, and be nonempty and no larger than 10 MiB. Do not send a public URL or base64 data.

Cost and retries

Check the current image rates on the pricing page. The charge depends on resolution, quality, and the number of reference images. cost.amount_usd on the returned job shows the charge. Set max_cost_usd to a decimal USD string with up to six decimal places to cap the charge. A quote above your cap returns 400 max_cost_exceeded before charging. A failed or canceled job receives a refund, reported in cost.refunded_usd. See Idempotency for safe retries and Jobs and polling for output retention.