Skip to content

Image Generation

Generate images from text descriptions using an OpenAI-compatible endpoint.

POST /v1/images/generations

Required capability: images

Request Body

ParameterTypeRequiredDescription
modelstringYesImage generation model (e.g. dall-e-3, stable-diffusion-xl).
promptstringYesText description of the desired image (1-4000 characters).
nintegerNoNumber of images to generate (1-10). Defaults to 1.
sizestringNoImage dimensions in WIDTHxHEIGHT format (e.g. 1024x1024, 1792x1024).
qualitystringNoImage quality setting (model-dependent, e.g. "standard", "hd").
stylestringNoImage style (model-dependent, e.g. "natural", "vivid").
response_formatstringNo"url" to receive a URL, or "b64_json" for base64-encoded image data.

Response

{
"created": 1709000000,
"data": [
{
"url": "https://cdn.example.com/generated-image.png",
"revised_prompt": "A detailed oil painting of a sunset over mountains..."
}
]
}

When response_format is "b64_json":

{
"created": 1709000000,
"data": [
{
"b64_json": "/9j/4AAQSkZJRg...",
"revised_prompt": "A detailed oil painting of a sunset over mountains..."
}
]
}

Response Fields

FieldTypeDescription
createdintegerUnix timestamp of when the image was generated.
dataarrayArray of generated image objects.
data[].urlstringURL of the generated image (when response_format is "url").
data[].b64_jsonstringBase64-encoded image data (when response_format is "b64_json").
data[].revised_promptstringThe prompt as revised by the model (if applicable).

Real-Time Progress

For providers that support it (such as ComfyUI), image generation progress updates are emitted via WebSocket on the /image-progress namespace. Connect to receive percentage updates during long-running generation jobs.

Example

Terminal window
curl https://your-gateway.example.com/v1/images/generations \
-H "Authorization: Bearer aigw_sk_your_api_key" \
-H "Content-Type: application/json" \
-d '{
"model": "dall-e-3",
"prompt": "A watercolor painting of a mountain lake at sunrise",
"size": "1024x1024",
"quality": "hd",
"n": 1
}'