Create image variation

POSThttps:/api.openai.com/v1/images/variations

Creates a variation of a given image. This endpoint only supports dall-e-2.

Request body

  • image
    string
    Required
    The image to use as the basis for the variation(s). Must be a valid PNG file, less than 4MB, and square.
  • model
    string

    The model to use for image generation. Only dall-e-2 is supported at this time.

    • model
      string
    • model
      string
      • dall-e-2
        string
  • n
    integer or null
    Defaults: 1
    The number of images to generate. Must be between 1 and 10.
  • response_format
    string or null
    Defaults: url

    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 has been generated.

    • url
      string
    • b64_json
      string
  • size
    string or null
    Defaults: 1024x1024

    The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024.

    • 256x256
      string
    • 512x512
      string
    • 1024x1024
      string
  • user
    string

    A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.

Response

Returns a list of image objects.

Example request
1
curl https://api.openai.com/v1/images/variations \
2
-H "Authorization: Bearer $OPENAI_API_KEY" \
3
-F image="@otter.png" \
4
-F n=2 \
5
-F size="1024x1024"
Example response
1
{
2
"created": 1589478378,
3
"data": [
4
{
5
"url": "https://..."
6
},
7
{
8
"url": "https://..."
9
}
10
]
11
}
Built with