所有画图(异步)
方法: POST路径: /v1/images/generations
支持所有画图模型异步请求,仅需添加 query 参数 async=true,请求body 与之前一致即可;
提交图像生成请求: 使用 POST /v1/images/generations 提交图像生成请求并传递参数(如 size、prompt、model 等)。 响应中返回一个 task_id,此 task_id 用于后续查询图像生成状态。
查询图像生成结果: 使用 GET /v1/images/tasks/{task_id} 查询生成任务的状态。如果任务完成,响应会包含生成的图像 URL。
请求参数
Query 参数
text
async
string
启用异步模式
必需
示例:
true
webhook
string
可选
示例:
https://www.baidu.com/notifyHeader 参数
text
Content-Type
string
必需
示例:
application/json
Authorization
string
可选
默认值:
Bearer {{YOUR_API_KEY}}Body 参数 application/json
text
prompt
string
必需
model
string
必需
示例
{
"size"
:
"1024x1024"
,
"prompt"
:
"cat"
,
"model"
:
"sora_image"
,
"n"
:
1
}请求示例代码
Shell
bash
curl --location --request POST '/v1/images/generations?async=true&webhook=https://www.baidu.com/notify' \
--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
--header 'Content-Type: application/json' \
--data-raw '{
"size": "1024x1024",
"prompt": "cat",
"model": "sora_image",
"n": 1
}'返回响应
🟢 200 成功
内容类型: application/json
响应结构
text
code
string
必需
message
string
必需
data
string
task id
必需示例
json
{
"task_id": "3dad96708a77485e97ac7ef652796d7b"
}