Skip to main content

Generate Images

Create images. Standard image models return data[] synchronously; models configured as async-only return an image task first, then you poll GET /v1/images/generations/{task_id} for the result.

To use the Aliyun-native input / parameters request format, see Aliyun Image Generation.

Try It

POST/v1/images/generationshttps://api-platform.ope.ai

Authentication

Uses Bearer Token authentication.

  • Header: Authorization: Bearer <token>
  • Example: Authorization: Bearer sk-xxxxxx

Request body (application/json)

FieldTypeRequiredDescriptionDefault / Range
modelstringYesModel for image generationqwen-image-2.0
promptstringYesText description of the image-
nintegerNoNumber of images to generateDefault: 1
sizestringNoGenerated image size. Use lowercase x between width and heightDefault: 1024x1024; example: 1024x1024
qualitystringNoGeneration quality, passed through to the upstream modelDefault: auto
response_formatstringNoSynchronous response formatDefault: b64_json; allowed: b64_json, url
imagestring / array / objectNoImage input. When provided, the request is treated as image edit mode. Supports image URLs, Data URLs/base64, arrays, or objects-
output_formatstringNoOutput format for GPT Image style modelsPassed through when supported by the model
output_compressionintegerNoOutput compression for GPT Image style modelsPassed through when greater than 0
backgroundstringNoBackground option for GPT Image style modelsPassed through when supported by the model
moderationstringNoModeration option for GPT Image style modelsPassed through when supported by the model
stylestringNoStyle option for non-GPT Image modelsPassed through when supported by the model
userstringNoEnd-user identifier, passed through upstream-
sequential_image_generationstringNoPlatform extension for sequential image generationAllowed: disabled, auto
watermarkbooleanNoWhether to request a watermarkDefault: false
streambooleanNoStreaming extensiontrue is not supported on the OpenAI image relay yet

Tip: if size uses a multiplication symbol instead of the letter x, the backend returns a parameter error. Use a value such as 1024x1024.

Response modes

ModeTriggerResponseNext step
SynchronousStandard image modelsOpenAI-style created, data[], and usageRead data[].url or data[].b64_json directly
Async taskModel has features.async_only=trueimage.generation.task objectUse the returned task_id with Get image generation task

For async tasks, if the upstream only returns b64_json, the platform stores the image and returns a public url in the task result. Successful task results are retained for 24 hours.

Request examples

The domain below is an example: https://api-platform.ope.ai.

curl -X POST "https://api-platform.ope.ai/v1/images/generations" \
-H "Authorization: Bearer $OPEAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image-2.0",
"prompt": "Generate an image showcasing AI image generation capabilities.",
"size": "1024x1024",
"n": 1,
"quality": "auto"
}'

Image input example

Clients still call /v1/images/generations. When image is provided, the platform treats the request as image edit mode; OpenAI / Azure upstream channels forward it to the upstream image edit endpoint.

curl -X POST "https://api-platform.ope.ai/v1/images/generations" \
-H "Authorization: Bearer $OPEAI_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "qwen-image-2.0",
"prompt": "Keep the subject and change the background to a clean product studio.",
"image": "https://example.com/input.png",
"size": "1024x1024",
"quality": "auto"
}'

Response examples

{
"created": 1777440000,
"data": [
{
"url": "https://example.com/generated-image.png",
"b64_json": "",
"revised_prompt": "Generate an image showcasing AI image generation capabilities."
}
],
"usage": {
"generated_images": 1,
"total_tokens": 100,
"input_tokens": 24,
"output_tokens": 76,
"input_tokens_details": {
"text_tokens": 24,
"image_tokens": 0
}
}
}