Creates an image from the prompt.
This function returns data from OpenAI API response. To display the generated image from the URL immediately in the result, use openai.createRemoteImage.
createImage(params)
params
An string with prompt or an object with request parameters:
prompt
A text description of the image.
model optional
A model to use (for example, "dall-e-2", “dall-e-3”). Defaults to "dall-e".
n optional
The number of images to generate (1 to 10, defaults to 1).
size optional
A string with the size of images to generate: "256x256", "512x512", or "1024x1024".
response_format optional
"url" (remote image URL) or "b64_url" (image data included with response as base64-encoded text). Defaults to "url".
user optional
A unique identifier of the end user.
An object containing response from OpenAI API.
let result = await openai.createImage({
prompt: "Oriental cat, painting by Dali",
size: "256x256"
})
print(JSON.stringify(result, null, 2))
new RemoteImage(result.data[0].url)
{
created: 1677109449,
data: [{
url: https://...
}]
}