openai.createImage

Creates an image from the prompt.

Note

This function returns data from OpenAI API response. To display the generated image from the URL immediately in the result, use openai.createRemoteImage.

Syntax

createImage(params)

Parameters

Return value

An object containing response from OpenAI API.

Example

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://...
        }]
}



External resources

See also