Skip to main content
POST
Generate Image

Body

application/json

Request parameters for generating images using AI models

model
string
required

The model to use for image generation (e.g., "dall-e-2", "dall-e-3", "imagen-3.0-generate-001").

prompt
string
required

A text description of the desired image(s).

background
string | null

The background color to use for transparency. Defaults to "auto". OpenAI only.

moderation
string | null

The moderation level to apply to the generated image. OpenAI only.

n
integer<int32> | null

The number of images to generate.

Required range: x >= 0
output_compression
integer<int32> | null

The compression level for the output image, ranging from 0 to 100. Higher values mean more compression. OpenAI only.

Required range: x >= 0
output_format
string | null

The format of the output image (e.g., "png", "jpeg"). OpenAI only.

quality
string | null

The quality of the image that will be generated. "hd" creates images with finer details and greater consistency. Not supported for all models.

response_format
string | null

The format in which the generated images are returned. Must be one of "url" or "b64_json". URLs are only valid for 60 minutes after the image is generated.

size
string | null

The size of the generated images. Not supported for all models.

style
string | null

The style of the generated images. Must be one of "vivid" or "natural". Vivid causes the model to lean towards generating hyper-real and dramatic images. Natural causes the model to produce more natural, less hyper-real looking images. Not supported for all models.

Response

Image generated successfully

Response from an image generation request

data
object[]
required

Array containing the generated image(s).

background
string | null

The background color used for transparency. OpenAI only.

created
integer<int64> | null

The Unix timestamp (in seconds) of when the image was generated.

Required range: x >= 0
output_format
string | null

The format of the output image. OpenAI only.

quality
string | null

The quality setting used for image generation. OpenAI only.

size
string | null

The size of the generated image. OpenAI only.

usage
null | object

Token usage information for the image generation request. OpenAI only.