Skip to content

Generate image

POST
/v1/images/generations
curl --request POST \
--url https://api.mirapi.ai/v1/images/generations \
--header 'Authorization: Bearer <token>' \
--header 'Content-Type: application/json' \
--data '{ "model": "gpt-image-1", "prompt": "A cute baby sea otter", "n": 1, "size": "1024x1024" }'

Creates an image given a prompt. Learn more.

Media typeapplication/json
object
model

The model to use for image generation. One of dall-e-2, dall-e-3 or gpt-image-1. Defaults to dall-e-2 unless a parameter specific to gpt-image-1 is used.

string
prompt
required

A text description of the desired image(s). The maximum length is 32000 characters for gpt-image-1, 1000 characters for dall-e-2 and 4000 characters for dall-e-3.

string
n

The number of images to generate. Must be between 1 and 10. For dall-e-3, only n=1 is supported.

integer
size

The size of the generated images. Must be one of 1024x1024, 1536x1024 (landscape), 1024x1536 (portrait), or auto (default value) for gpt-image-1, one of 256x256, 512x512, or 1024x1024 for dall-e-2, and one of 1024x1024, 1792x1024, or 1024x1792 for dall-e-3.

string
background

Allows to set transparency for the background of the generated image(s). This parameter is only supported for gpt-image-1. Must be one of transparent, opaque or auto (default value). When auto is used, the model will automatically determine the best background for the image.

If transparent, the output format needs to support transparency, so it should be set to either png (default value) or webp.

string
moderation

Control the content-moderation level for images generated by gpt-image-1. Must be either low for less restrictive filtering or auto (default value).

string
quality

The quality of the image that will be generated.

string
stream
string
style
string
user
string
Example
{
"model": "gpt-image-1",
"prompt": "A cute baby sea otter",
"n": 1,
"size": "1024x1024"
}
Media typeapplication/json
object
created
required
integer
data
required
Array<object>
object
b64_json
string
url
required
string
usage
required
object
total_tokens
required
integer
input_tokens
required
integer
output_tokens
required
integer
input_tokens_details
required
object
text_tokens
required
integer
image_tokens
required
integer
Example
{
"created": 1713833628,
"data": [
{
"b64_json": "..."
}
],
"usage": {
"total_tokens": 100,
"input_tokens": 50,
"output_tokens": 50,
"input_tokens_details": {
"text_tokens": 10,
"image_tokens": 40
}
}
}