Skip to main content
POST
/
v1
/
images
/
generations
OpenAI image generations
curl --request POST \
  --url http://sandbox.mintlify.com/v1/images/generations \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "prompt": "一只可爱的小猫在花园里玩耍,阳光明媚,油画风格",
  "model": "gpt-image-1",
  "size": "1024x1024",
  "quality": "high"
}
'
{
  "created": 1589478378,
  "background": "auto",
  "output_format": "png",
  "quality": "high",
  "size": "1024x1024",
  "data": [
    {
      "url": "https://example.com/generated-image.png"
    }
  ],
  "usage": {
    "input_tokens": 15,
    "input_tokens_details": {
      "image_tokens": 0,
      "text_tokens": 15
    },
    "output_tokens": 1,
    "total_tokens": 16
  }
}
Create images from text prompts.
  • Authenticate with Authorization: Bearer {API_KEY}
  • Use this as the text-to-image route; for edits, inpainting, or image expansion, use /v1/images/edits
  • gpt-image-1, dall-e-3, and dall-e-2 expose different parameter sets, and those differences are now rendered in the native parameter panel above
  • If the response contains temporary url values, mirror them server-side quickly; if it contains b64_json, avoid decoding too many large images on the main thread

Authorizations

Authorization
string
header
required

Bearer authentication header of the form Bearer <token>, where <token> is your auth token.

Body

application/json
prompt
string
required

Text prompt for the desired image.

Example:

"一只可爱的小猫在花园里玩耍,阳光明媚,油画风格"

model
enum<string>

Image generation model.

Available options:
gpt-image-1,
dall-e-3,
dall-e-2
background
enum<string>

Only supported by gpt-image-1.

Available options:
transparent,
opaque,
auto
moderation
enum<string>

Only supported by gpt-image-1.

Available options:
auto,
low
n
integer
default:1

Number of images to generate. dall-e-3 only supports 1.

Required range: 1 <= x <= 10
output_compression
integer
default:100

Compression level for gpt-image-1 jpeg/webp output.

Required range: 0 <= x <= 100
output_format
enum<string>

Only supported by gpt-image-1.

Available options:
png,
jpeg,
webp
partial_images
integer
default:0

Number of partial images for streaming previews.

Required range: 0 <= x <= 3
quality
enum<string>

Supported values vary by model.

Available options:
auto,
high,
medium,
low,
hd,
standard
response_format
enum<string>

Only applies to dall-e-2 and dall-e-3.

Available options:
url,
b64_json
size
enum<string>

Allowed values depend on the selected model.

Available options:
1024x1024,
1536x1024,
1024x1536,
auto,
256x256,
512x512,
1792x1024,
1024x1792
stream
boolean
default:false

Only supported by gpt-image-1.

style
enum<string>

Only supported by dall-e-3.

Available options:
vivid,
natural
user
string

Unique identifier for the end user.

Response

Successful image generation response

created
integer<int64>
required

Unix timestamp in seconds.

data
object[]
required
background
enum<string>
Available options:
transparent,
opaque,
auto
output_format
enum<string>
Available options:
png,
jpeg,
webp
quality
enum<string>
Available options:
auto,
high,
medium,
low,
hd,
standard
size
string
usage
object