Skip to main content
POST
/
v1
/
images
/
variations
Create Image Variation
curl --request POST \
  --url https://api.example.com/v1/images/variations \
  --header 'Content-Type: application/json' \
  --data '
{
  "model": "<string>",
  "n": 123,
  "size": "<string>",
  "response_format": "<string>",
  "user": "<string>"
}
'
{
  "created": 123,
  "data": [
    {
      "url": "<string>",
      "b64_json": "<string>"
    }
  ]
}
Creates variations of a given image. DALL-E 2 only.

Method

client.images.createVariation(params)

Request Parameters

image
File
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 variation generation. Currently only openai/dall-e-2 is supported.
n
number
The number of images to generate. Must be between 1 and 10.Default: 1
size
string
The size of the generated images. Must be one of 256x256, 512x512, or 1024x1024.Default: 1024x1024
response_format
string
The format in which the generated images are returned:
  • url - URLs valid for 60 minutes
  • b64_json - Base64-encoded JSON
Default: url
user
string
A unique identifier representing your end-user, which can help OpenAI monitor and detect abuse.

Response

created
number
required
Unix timestamp when images were created.
data
array
required
List of generated images.

Examples

import fs from "fs";

const variation = await client.images.createVariation({
  image: fs.createReadStream("original.png"),
  model: "openai/dall-e-2"
});

console.log(variation.data[0].url);

Build docs developers (and LLMs) love