Create Image

POST/v1/images/generations
Generate one or more images from a text prompt.

Request Body

application/json
model:requiredenum<string>

Image generation model. Use gpt-image-2-c for 1K/2K output or gpt-image-2-4k-c for 4K output.

Allowedgpt-image-2-cgpt-image-2-4k-c
Examplegpt-image-2-c
prompt:requiredstring

Text instruction describing the requested output.

size:optionalenum<string>

Output dimensions. Use a listed preset or a custom WxH value. Custom sizes must have a maximum edge of 3840 px, both edges divisible by 16, an aspect ratio no greater than 3:1, and 655,360–8,294,400 total pixels.

Allowed1024x10241536x10242048x15361024x15361536x20481440x21602048x20482880x28803200x25602560x32003264x24482448x32643504x23362336x35043840x21602160x38403696x1584auto
Exampleauto

Response

200

A successful request returns a JSON response. The complete example is shown in the code panel.