Skip to main content
POST
OpenAI image generation
This endpoint is compatible with the OpenAI Images protocol and generates images from a text prompt. You can reuse the parameter structure from the official OpenAI documentation directly in the request body.

Features

  • Compatible with the OpenAI Images API request structure, so existing integration code migrates seamlessly
  • Supports batch generation through the n parameter to return multiple images at once
  • Supports png, jpeg, and webp output formats with output_compression control
  • Supports background settings via background (transparent / opaque / auto)
  • Supports both url and b64_json response formats
  • Supports streaming (SSE) responses with intermediate results pushed via partial_images
  • Supports generation parameters such as quality, size, and style

Authentication

Include the Authorization header in the format Bearer YOUR_API_KEY.

Supported image models

Available image models in the Model Square, please refer to Model List.

Quick example

A successful generation returns the image data:

Next steps

Headers

Authorization
string
required

API Key token (Bearer sk-xxx)

Content-Type
string

Body

application/json
prompt
string
required

Text prompt

model
string
required

Model name

background
string

Background of the generated image: "transparent" / "opaque" / "auto"; defaults to "auto"

moderation
string

Content moderation mode

n
integer

Number of images to generate

output_compression
integer

Output compression level

output_format
string

Output image format, e.g. "png", "jpeg", "webp"

partial_images
integer

Number of intermediate result images pushed per update in streaming responses

response_format
string

Response format, "url" or "b64_json"

quality
string

Image quality, e.g. "high", "medium", "low", and "auto"; defaults to "auto"

size
string

Image size, e.g. "1024x1024"

stream
boolean

Whether to use streaming (SSE) responses

style
string

Image style, e.g. "vivid", "natural" (DALL-E 3 feature)

user
string

End-user identifier for monitoring and abuse detection

Response

200 - application/json
created
integer<int64>

Image generation timestamp (Unix seconds)

background
string

Background image data echo

data
object[]

Generated image data list

output_format
string

Output image format echo

quality
string

Image quality echo

size
string

Image size echo

usage
object

Token and image usage statistics