Image Generation (Async)
GPT Image async image generation endpoint
The GPT Image async image generation endpoint. Submits a generation task from a prompt. The interface is async: on success it returns an image.task object; poll the Query Result endpoint with the returned task ID until status becomes completed to fetch the final image.
Billing model
This endpoint is billed under the gpt-image model. Configure a group price for it on the channel, and your token must be allowed to use that model's group.
Async flow
POST /v1/images/async/generationssubmits the task and returnstask_id(prefixed withtask_) andstatus=queued/in_progress;- Poll
GET /v1/images/async/generations/{task_id}with thattask_id; - When
status=completed, thedataarray contains the final image (b64_jsonBase64); whenfailed,errorexplains why.
Image-to-image (reference images)
This endpoint also supports image-to-image: pass reference images in the images array (each item a public image URL or a Base64 data URI) and describe the keep/edit instructions in prompt. For a single reference image you can also use the image field with one string. Image-to-image uses the same submit & query flow, endpoint, and billing model as text-to-image.
Use the request example selector below the endpoint (Text-to-image / Image-to-image) to switch between the two request bodies; the reference image is passed in via images.
Authorization
BearerAuth
使用 Bearer Token 认证。
格式: Authorization: Bearer sk-xxxxxx
令牌需开通对应模型的调用权限。
In: header
Request Body
application/json
模型名称
提示词,描述希望生成的图片内容
参考图列表(图生图)。每项为图片 URL(http/https)或 Base64 data URI,配合 prompt 描述修改要求。仅一张时也可用 image 字段传单个字符串
单张参考图(图生图),参考图 URL 或 Base64 data URI。多张请用 images 数组
生成数量(1-128),默认 1
1 <= value <= 128图片尺寸,如 1024x1024、1536x1024、1024x1536 等
画质等级:low / medium / high / auto
背景:transparent / opaque / auto / none
输出格式:png / jpeg / webp
内容审核:auto / low / high
终端用户标识,用于审计与追踪
Response Body
application/json
application/json
curl -X POST "https://www.omwai.xyz/v1/images/async/generations" \ -H "Content-Type: application/json" \ -d '{ "model": "gpt-image", "prompt": "a cute cat, cyberpunk style, neon background", "size": "1024x1024", "quality": "high" }'{
"id": "task_01J8ABCDEFGHIJKLMNOPQRST",
"task_id": "task_01J8ABCDEFGHIJKLMNOPQRST",
"object": "image.task",
"model": "gpt-image",
"status": "queued",
"progress": "0%",
"created_at": 1788256630,
"completed_at": 1788256720,
"error": {
"code": "string",
"message": "string"
},
"data": [
{
"b64_json": "string",
"revised_prompt": "string"
}
]
}{
"code": "string",
"message": "string"
}Note
A successful submission (HTTP 200) only means the task was accepted, not that the image is ready. Always poll the query endpoint until status=completed.
How is this guide?
Last updated on