Create image
POST
https://api.openai.com/v1/images/generationsGiven a prompt and/or an input image, the model will generate a new image.
Related guide: Image generation
Creates an image given a prompt.
Request
Header Params
Authorization
string
optional
Example:
Bearer {{YOUR_API_KEY}}
Body Params application/json
prompt
string
required
A text description of the desired image(s). The maximum length is 1000 characters.
n
integer
optional
The number of images to generate. Must be between 1 and 10.
size
string
optional
The size of the generated images. Must be one of 256x256
, 512x512
, or 1024x1024
.
response_format
string
required
The format in which the generated images are returned. Must be one of url
or b64_json
.
user
string
required
A unique identifier representing your end-user, which can help OpenAI to monitor and detect abuse. Learn more.
Example
{
"prompt": "A colorful sunset over the mountains",
"n": 2,
"size": "1024x1024"
}
Request samples
Responses
Create image(200)
HTTP Code: 200
Content Type : JSONapplication/json
Data Schema
created
integer
required
data
array [object {1}]
required
url
string
required
ExampleCreate image
{
"created": 1589478378,
"data": [
{
"url": "https://..."
},
{
"url": "https://..."
}
]
}
Last modified: a year ago