GPT Image1.5 文生图
本页由 ModelFold 文档站根据上游官方 OpenAPI 文档同步生成。接口路径、参数、示例与官方保持一致;品牌与 API 域名已替换为 ModelFold。
接口
POST /jobs/createTask
完整 URL: https://ai.modelfold.online/v1/jobs/createTask
鉴权:所有请求都需要
Authorization: Bearer <API_KEY>请求头。
概述
使用 GPT Image 1.5 文本转图像模型生成内容。该过程包含两个步骤:创建生成任务和查询任务状态及结果。
查询任务状态
提交任务后,使用统一的查询端点检查进度并检索结果:
- 获取任务详情 — 了解如何查询任务状态和检索生成结果
TIP
对于生产使用,我们建议使用 callBackUrl 参数接收生成完成时的自动通知,而不是轮询状态端点。
相关资源
请求参数
请求体 (application/json)
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
model | string | 是 | 用于生成的模型名称。必填字段。 - 此端点必须使用 gpt-image/1.5-text-to-image 默认值:"gpt-image/1.5-text-to-image"。 可选值:gpt-image/1.5-text-to-image。 示例:gpt-image/1.5-text-to-image。 |
callBackUrl | string | 否 | 接收生成任务完成更新的 URL。可选但建议在生产环境中使用。 - 当生成完成时,系统将向此 URL POST 任务状态和结果 - 回调包含生成的内容 URL 和任务信息 - 您的回调端点应接受包含结果的 JSON 负载的 POST 请求 - 或者,使用获取任务详情端点轮询任务状态 - 为确保回调安全性,请参阅 Webhook 校验指南 了解签名验证实现方法 示例: https://your-domain.com/api/callback。 |
input | object | 是 | 生成任务的输入参数 |
input.prompt | string | 是 | 描述您想要生成的图像的文本提示 示例:Create a photorealistic candid photograph of an elderly sailor standing on a small fishing boat. He has weathered skin with visible wrinkles, pores, and sun texture, and a few faded traditional sailor tattoos on his arms. He is calmly adjusting a net while his dog sits nearby on the deck. Shot like a 35mm film photograph, medium close-up at eye level, using a 50mm lens. The image should feel honest and unposed, with real skin texture, worn materials, and everyday detail. No glamorization, no heavy retouching. 。 |
input.aspect_ratio | string | 是 | 必填。图像的宽高比,决定其视觉形式。 可选值:1:1 / 2:3 / 3:2。 示例:1:1。 |
input.quality | string | 是 | 必填。质量:medium=平衡,high=慢速/详细。 可选值:medium / high。 示例:medium。 |
请求示例
bash
curl -X POST "https://ai.modelfold.online/v1/jobs/createTask" \
-H "Authorization: Bearer $MODELFOLD_API_KEY" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-image/1.5-text-to-image",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "Create a photorealistic candid photograph of an elderly sailor standing on a small fishing boat. He has weathered skin with visible wrinkles, pores, and sun texture, and a few faded traditional sailor tattoos on his arms. He is calmly adjusting a net while his dog sits nearby on the deck. Shot like a 35mm film photograph, medium close-up at eye level, using a 50mm lens. The image should feel honest and unposed, with real skin texture, worn materials, and everyday detail. No glamorization, no heavy retouching. ",
"aspect_ratio": "1:1",
"quality": "medium"
}
}'json
{
"model": "gpt-image/1.5-text-to-image",
"callBackUrl": "https://your-domain.com/api/callback",
"input": {
"prompt": "Create a photorealistic candid photograph of an elderly sailor standing on a small fishing boat. He has weathered skin with visible wrinkles, pores, and sun texture, and a few faded traditional sailor tattoos on his arms. He is calmly adjusting a net while his dog sits nearby on the deck. Shot like a 35mm film photograph, medium close-up at eye level, using a 50mm lens. The image should feel honest and unposed, with real skin texture, worn materials, and everyday detail. No glamorization, no heavy retouching. ",
"aspect_ratio": "1:1",
"quality": "medium"
}
}响应
200 — 请求成功
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
code | integer | 是 | 请求状态码。请求失败时 HTTP 状态仍为 200,请始终以本字段判断:200 表示成功,其他值均表示失败,原因见 msg。常见值:401 API key 无效或缺失;402 积分不足;429 超出频率限制;422 或 500 请求未能处理(请先查看 msg、检查参数,再决定是否重试)。 可选值:200 / 401 / 402 / 404 / 422 / 429 / 433 / 455 / 500 / 501 / 505。 示例:200。 |
msg | string | 是 | 响应消息,失败时的错误描述 |
data | object | 是 | — |
data.taskId | string | 是 | 可以使用任务 ID 与“获取任务详细信息”端点一起查询任务状态。 |
json
{
"code": 200,
"msg": "success",
"data": {
"taskId": "task_gpt-image_1765968190655"
}
}回调
onImageGenerated
回调地址:{$request.body#/callBackUrl}(即请求体里的 callBackUrl)。
任务成功或失败时发送回调。
回调体参数
| 参数 | 类型 | 必填 | 说明 |
|---|---|---|---|
code | integer | 否 | 200:成功;501:失败,原因见 data.failCode 与 data.failMsg。 可选值:200 / 501。 示例:200。 |
msg | string | 否 | 状态消息 示例:Playground task completed successfully.。 |
data | object | 否 | — |
data.completeTime | integer | 否 | 任务完成时间,Unix 毫秒时间戳 示例:1786432137000。 |
data.costTime | integer | 否 | 处理耗时(秒),成功和失败回调都会返回。 示例:82。 |
data.createTime | integer | 否 | 任务创建时间,Unix 毫秒时间戳 示例:1786432054000。 |
data.creditsConsumed | number | 否 | 本任务消耗的积分;失败任务为 0。 示例:4。 |
data.model | string | 否 | 图片生成使用的模型 示例:gpt-image/1.5-text-to-image。 |
data.param | string | 否 | 创建任务时提交的参数,JSON 字符串格式 示例:{"input":"{\"aspect_ratio\":\"1:1\",\"prompt\":\"拍摄一张写实感十足的素描照片,画面中一位年迈的水手站在一艘小渔船之上。他的皮肤因长期暴露在阳光下而显现出明显的皱纹、毛孔和晒伤痕迹,手臂上还留有几处褪色的传统水手纹身。他正平静地调整着渔网,身旁的狗则安静地坐在甲板上。照片采用35毫米胶片摄影风格,中等焦距、平视角度,使用50毫米镜头拍摄。画面应真实自然,无任何摆拍或修饰,保留真实的肌肤质感、磨损的材质以及日常细节。避免过度美化,也不进行过度修图处理。 \",\"quality\":\"medium\"}","callBackUrl":"https://your-domain.com/api/callback","model":"gpt-image/1.5-text-to-image"}。 |
data.resultJson | string | 否 | 图片生成结果,JSON 字符串格式。resultUrls 为生成图片的 URL 列表。仅在 state 为 success 时出现。 示例:{"resultUrls":["https://tempfile.aiquickdraw.com/images/chatgpt/file_000000008efc820c9ee0efb69a33e878.png"]}。 |
data.state | string | 否 | 任务状态 可选值:success / fail。 示例:success。 |
data.taskId | string | 否 | 任务 ID 示例:e1c45405bdaf3065e7e916bc3ff1cf55。 |
data.updateTime | integer | 否 | 完成时间请以 completeTime 为准;updateTime 可能与 createTime 相同。 示例:1786432137000。 |
data.failCode | string | 否 | 失败码,数字字符串,如 "400"、"500"。仅在 state 为 fail 时出现。 示例:500。 |
data.failMsg | string | 否 | 失败原因,仅在 state 为 fail 时出现。 示例:<error detail>。 |
成功
json
{
"code": 200,
"msg": "Playground task completed successfully.",
"data": {
"taskId": "e1c45405bdaf3065e7e916bc3ff1cf55",
"model": "gpt-image/1.5-text-to-image",
"state": "success",
"param": "{\"input\":\"{\\\"aspect_ratio\\\":\\\"1:1\\\",\\\"prompt\\\":\\\"拍摄一张写实感十足的素描照片,画面中一位年迈的水手站在一艘小渔船之上。他的皮肤因长期暴露在阳光下而显现出明显的皱纹、毛孔和晒伤痕迹,手臂上还留有几处褪色的传统水手纹身。他正平静地调整着渔网,身旁的狗则安静地坐在甲板上。照片采用35毫米胶片摄影风格,中等焦距、平视角度,使用50毫米镜头拍摄。画面应真实自然,无任何摆拍或修饰,保留真实的肌肤质感、磨损的材质以及日常细节。避免过度美化,也不进行过度修图处理。 \\\",\\\"quality\\\":\\\"medium\\\"}\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"model\":\"gpt-image/1.5-text-to-image\"}",
"resultJson": "{\"resultUrls\":[\"https://tempfile.aiquickdraw.com/images/chatgpt/file_000000008efc820c9ee0efb69a33e878.png\"]}",
"completeTime": 1786432137000,
"createTime": 1786432054000,
"costTime": 82,
"creditsConsumed": 4,
"updateTime": 1786432137000
}
}失败
json
{
"code": 501,
"msg": "Playground task failed.",
"data": {
"taskId": "e1c45405bdaf3065e7e916bc3ff1cf55",
"model": "gpt-image/1.5-text-to-image",
"state": "fail",
"param": "{\"input\":\"{\\\"aspect_ratio\\\":\\\"1:1\\\",\\\"prompt\\\":\\\"拍摄一张写实感十足的素描照片,画面中一位年迈的水手站在一艘小渔船之上。他的皮肤因长期暴露在阳光下而显现出明显的皱纹、毛孔和晒伤痕迹,手臂上还留有几处褪色的传统水手纹身。他正平静地调整着渔网,身旁的狗则安静地坐在甲板上。照片采用35毫米胶片摄影风格,中等焦距、平视角度,使用50毫米镜头拍摄。画面应真实自然,无任何摆拍或修饰,保留真实的肌肤质感、磨损的材质以及日常细节。避免过度美化,也不进行过度修图处理。 \\\",\\\"quality\\\":\\\"medium\\\"}\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"model\":\"gpt-image/1.5-text-to-image\"}",
"failCode": "500",
"failMsg": "<error detail>",
"completeTime": 1786432137000,
"createTime": 1786432054000,
"costTime": 82,
"creditsConsumed": 0,
"updateTime": 1786432137000
}
}