POST /v1/videos/v1/videos 接口调用 GPT 图片生成能力(与视频生成共用接口,通过 model 参数区分),支持文生图和图生图两种模式,采用异步任务方式,先提交返回任务 ID,再轮询获取结果。| model 参数 | 说明 |
|---|---|
gpt-image-2 | GPT 图片生成模型 |
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| Authorization | string | 是 | Bearer YOUR_API_KEY |
| Content-Type | string | 是 | application/json |
| 参数名 | 类型 | 必填 | 说明 |
|---|---|---|---|
| model | string | 是 | 模型名称,固定为 gpt-image-2 |
| prompt | string | 是 | 文本提示词,最大长度 10000 字符 |
| metadata | object | 否 | 元数据对象,包含图片生成的额外参数 |
| metadata.size | string | 否 | 图片尺寸,格式 宽x高,如 1080x1920(竖屏)、1920x1080(横屏),默认由上游决定 |
| metadata.urls | string[] | 否 | 参考图片数组(支持 Base64 或 URL),最多 5 张。传此参数为图生图模式,不传或为空为文生图模式 |
{
"model": "gpt-image-2",
"prompt": "生成竖屏图片 xxx抖音带货",
"metadata": {
"size": "1080x1920",
"urls": []
}
}| 参数名 | 类型 | 说明 |
|---|---|---|
| id | string | 任务 ID,格式:gpt_img_xxx |
| object | string | 对象类型,固定值:image |
| model | string | 使用的模型名称 |
| status | string | 任务状态:queued(排队中)、in_progress(处理中)、completed(已完成)、failed(失败) |
| progress | number | 任务进度,0-100 |
| created_at | number | 创建时间戳(秒) |
| completed_at | number | 完成时间戳(秒),仅在 completed 状态返回 |
| video_url | string | 生成的图片 URL(与视频接口字段保持一致,实际为图片地址),仅在 completed 状态返回 |
| error | object | 错误信息,仅在 failed 状态返回 |
{
"id": "gpt_img_1776831820897_6i7lyuxzd",
"object": "image",
"model": "gpt-image-2",
"status": "queued",
"progress": 0,
"created_at": 1709876543
}{
"id": "gpt_img_1776831820897_6i7lyuxzd",
"object": "image",
"model": "gpt-image-2",
"status": "in_progress",
"progress": 10,
"created_at": 1709876543
}{
"id": "gpt_img_1776831820897_6i7lyuxzd",
"object": "image",
"model": "gpt-image-2",
"status": "completed",
"progress": 100,
"created_at": 1709876543,
"completed_at": 1709876598,
"video_url": "https://example.com/uploads/gpt-images/gpt_img_1776831820897_6i7lyuxzd.png"
}{
"id": "gpt_img_1776831820897_6i7lyuxzd",
"object": "image",
"model": "gpt-image-2",
"status": "failed",
"progress": 0,
"created_at": 1709876543,
"error": {
"message": "内容不符合安全规范,请修改提示词或更换参考图片后重试",
"code": "upstream_error"
}
}GET /v1/videos/{task_id}status 字段判断任务是否完成:queued / in_progress:任务未完成,继续轮询completed:任务完成,从 video_url 字段获取图片地址failed:任务失败,从 error.message 获取错误原因/v1/videos 接口,与视频生成共用,通过 model 参数区分(gpt-image-2 为 GPT 图片生成)metadata 对象中1080x19201920x10801024x1024、1024x1792)data:image/jpeg;base64,)metadata.urls 为空数组或不传 = 文生图模式metadata.urls 包含图片(Base64 或 URL) = 图生图模式GET /v1/videos/{task_id} 查询任务进度和结果,建议轮询间隔 2~5 秒video_url 字段中,实际内容为图片curl --location 'https://api.dyuapi.com/v1/videos' \
--header 'Authorization: Bearer {{YOUR_API_KEY}}' \
--header 'Content-Type: application/json' \
--data '{
"model": "gpt-image-2",
"prompt": "根据图片做一个广告",
"metadata": {
"size": "1080x1920",
"urls": [
"https://res.papir.cc/user-upload/creati-web-app/2026-04-18/1776519962551vv1AXmBu-ZMWqAckJIbt81167-600x751h.jpg",
"https://www.baidu.com/img/PCtm_d9c8750bed0b3c7d089fa7d55720d6cf.png"
]
}
}'{}