gpt-image-1

This documentation is valid for the following list of our models:

  • openai/gpt-image-1

Model Overview

A powerful multimodal model capable of generating new images, combining existing ones, and applying image masks — all guided by a text prompt.

Setup your API Key

If you don’t have an API key for the AI/ML API yet, feel free to use our Quickstart guide.

API Schemas

Note that by default, the quality parameter is set to 'medium'. The output image will still look great, but for even more detailed results, consider setting this parameter to 'high'.

Generate image

post
Body
modelstring · enumRequiredPossible values:
promptstring · max: 32000Required

The text prompt describing the content, style, or composition of the image to be generated.

backgroundstring · enumOptional

Allows to set transparency for the background of the generated image(s). When auto is used, the model will automatically determine the best background for the image. If transparent, the output format needs to support transparency, so it should be set to either png (default value) or webp.

Default: autoPossible values:
moderationstring · enumOptional

Control the content-moderation level for images.

Default: autoPossible values:
nnumber · enumOptional

The number of images to generate.

Default: 1Possible values:
output_compressioninteger · max: 100Optional

The compression level (0-100%) for the generated images.

Default: 100
output_formatstring · enumOptional

The format of the generated image.

Default: pngPossible values:
qualitystring · enumOptional

The quality of the image that will be generated.

Default: mediumPossible values:
sizestring · enumOptional

The size of the generated image.

Default: 1024x1024Possible values:
response_formatstring · enumOptional

The format in which the generated images are returned.

Default: urlPossible values:
Responses
200Success
application/json
post
/v1/images/generations
200Success

Edit image

post
Authorizations
AuthorizationstringRequired

Bearer key

Body
modelstring · enumRequiredPossible values:
promptstring · max: 32000Required

The text prompt describing the content, style, or composition of the image to be generated.

imagestring · binaryRequired

The image(s) to edit. Must be a supported image file or an array of images. Each image should be a png, webp, or jpg file less than 50MB. You can provide up to 16 images.

maskstring · binaryOptional

An additional image whose fully transparent areas (e.g. where alpha is zero) indicate where image should be edited. If there are multiple images provided, the mask will be applied on the first image. Must be a valid PNG file, less than 4MB, and have the same dimensions as image.

backgroundstring · enumOptional

Allows to set transparency for the background of the generated image(s). When auto is used, the model will automatically determine the best background for the image. If transparent, the output format needs to support transparency, so it should be set to either png (default value) or webp.

Default: autoPossible values:
nnumber · min: 1 · max: 10Optional

The number of images to generate.

Default: 1
output_compressioninteger · max: 100Optional

The compression level (0-100%) for the generated images.

Default: 100
output_formatstring · enumOptional

The format of the generated image.

Default: pngPossible values:
qualitystring · enumOptional

The quality of the image that will be generated.

Default: mediumPossible values:
sizestring · enumOptional

The size of the generated image.

Default: 1024x1024Possible values:
response_formatstring · enumOptional

The format in which the generated images are returned.

Default: urlPossible values:
Responses
post
/v1/images/edits
201

Successfully edited image

Quick Examples

Generate image

Let's generate an image of the specified size using a simple prompt.

Response

We obtained the following 1536x1024 image by running this code example (~ 26 s):

"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses. Realistic photo."
More images
"A T-Rex relaxing on a beach, lying on a sun lounger and wearing sunglasses."
"Racoon eating ice-cream"

Edit image: Combine images

Let's generate an image using two input images and a prompt that defines how they should be edited.

Our input images
t-rex.png
crown.png
Response

We obtained the following 1024x1024 image by running this code example (~ 34 s):

A true king of the monsters. On vacation.

Edit image: Use an image mask

In this example, we’ll provide the model with our previously generated image of a T-rex on a beach, along with a same-sized mask where the area occupied by the dinosaur is transparent (alpha = 0). In the prompt, we’ll ask the model to remove the masked object from the image and see how well it handles the task.

Image & Mask
Image
Mask
Response

We obtained the following 1024x1024 image by running this code example (~ 32 s).

Our dinosaur has disappeared into thin air!

Last updated

Was this helpful?