Skip to main content
POST
Generate image

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
model
enum<string>
required

Must be gpt-image-2.

Available options:
gpt-image-2
Example:

"gpt-image-2"

prompt
string
required

Text description of the desired image.

Example:

"A red fox sitting in a snowy forest at dusk, photorealistic"

n
integer
default:1

Number of images to generate.

Required range: 1 <= x <= 10
size
string

{width}x{height}. Edges must be multiples of 16, aspect ratio <= 3:1, total pixels 655,360-8,294,400, max edge 3,840px. Omit to let the model choose (~1.3M pixels).

Example:

"1536x1024"

quality
enum<string>
default:low

Rendering quality.

Available options:
low,
medium,
high,
auto
background
enum<string>
default:opaque

Background treatment. Use png output with transparent.

Available options:
opaque,
transparent,
auto
output_format
enum<string>
default:png

Output image format. webp is not supported.

Available options:
png,
jpeg
output_compression
integer

Compression level for jpeg output.

Required range: 0 <= x <= 100
moderation
enum<string>
default:auto

Content moderation strictness.

Available options:
auto,
low
stream
boolean
default:false

Stream partial images as server-sent events.

partial_images
integer

Number of preview frames to request when stream is true.

Response

Images generated successfully

created
integer

Unix timestamp of the generation.

background
string

Background treatment used.

output_format
string

Format of the returned images.

quality
string

Quality actually used.

size
string

Resolution actually used.

data
object[]
usage
object