Skip to content

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 图生图模型从输入图像生成图像。此模型允许您使用文本提示编辑或修改现有图像。该过程包含两个步骤:创建生成任务和查询任务状态及结果。

文件上传要求 ​

在使用此 API 之前,您需要上传图像文件:

第 1 步 · 上传图像

使用文件上传 API 上传您的源图像。

第 2 步 · 获取文件 URL

上传完成后,您将获得可在 input_urls 参数中使用的文件 URL。

WARNING

  • 支持格式:JPEG、PNG、WebP
  • 最大文件大小:10MB
  • 每个请求最多16个输入 URL
  • 图像内容应适当并遵循使用指南

查询任务状态 ​

提交任务后,使用统一的查询端点检查进度并检索结果:

TIP

对于生产使用,我们建议使用 callBackUrl 参数接收生成完成时的自动通知,而不是轮询状态端点。

相关资源 ​

请求参数 ​

请求体 (application/json) ​

参数类型必填说明
modelstring是用于生成的模型名称。必填字段。
- 此端点必须使用 gpt-image/1.5-image-to-image 默认值:"gpt-image/1.5-image-to-image"。 可选值:gpt-image/1.5-image-to-image。 示例:gpt-image/1.5-image-to-image。
callBackUrlstring否接收生成任务完成更新的 URL。可选但建议在生产环境中使用。
- 当生成完成时,系统将向此 URL POST 任务状态和结果
- 回调包含生成的内容 URL 和任务信息
- 您的回调端点应接受包含结果的 JSON 负载的 POST 请求
- 或者,使用获取任务详情端点轮询任务状态
- 为确保回调安全性,请参阅 Webhook 校验指南 了解签名验证实现方法 示例:https://your-domain.com/api/callback。
inputobject是生成任务的输入参数
  input.input_urlsarray&lt;string&gt;是上传图像文件作为 API 的输入(上传后的文件 URL,不是文件内容;接受类型:image/jpeg、image/png、image/webp;最大大小:10.0MB)
  input.promptstring是描述您想要生成的图像的文本提示 示例:Edit the image to dress the woman using the provided clothing images. Preserve her exact likeness, expression, hairstyle, and proportions. Replace only the clothing, fitting the garments naturally to her existing pose and body geometry with realistic fabric behavior. Match lighting, shadows, and color temperature to the original photo so the outfit integrates photorealistically, without looking pasted on.。
  input.aspect_ratiostring是必填。图像的宽高比,决定其视觉形式。 可选值:1:1 / 2:3 / 3:2。 示例:3:2。
  input.qualitystring是必填。质量: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-image-to-image",
  "callBackUrl": "https://your-domain.com/api/callback",
  "input": {
    "input_urls": [
      "https://static.aiquickdraw.com/tools/example/1765962794374_GhtqB9oX.webp"
    ],
    "prompt": "Edit the image to dress the woman using the provided clothing images. Preserve her exact likeness, expression, hairstyle, and proportions. Replace only the clothing, fitting the garments naturally to her existing pose and body geometry with realistic fabric behavior. Match lighting, shadows, and color temperature to the original photo so the outfit integrates photorealistically, without looking pasted on.",
    "aspect_ratio": "3:2",
    "quality": "medium"
  }
}'
json
{
  "model": "gpt-image/1.5-image-to-image",
  "callBackUrl": "https://your-domain.com/api/callback",
  "input": {
    "input_urls": [
      "https://static.aiquickdraw.com/tools/example/1765962794374_GhtqB9oX.webp"
    ],
    "prompt": "Edit the image to dress the woman using the provided clothing images. Preserve her exact likeness, expression, hairstyle, and proportions. Replace only the clothing, fitting the garments naturally to her existing pose and body geometry with realistic fabric behavior. Match lighting, shadows, and color temperature to the original photo so the outfit integrates photorealistically, without looking pasted on.",
    "aspect_ratio": "3:2",
    "quality": "medium"
  }
}

响应 ​

200 — 请求成功 ​

参数类型必填说明
codeinteger是请求状态码。请求失败时 HTTP 状态仍为 200,请始终以本字段判断:200 表示成功,其他值均表示失败,原因见 msg。常见值:401 API key 无效或缺失;402 积分不足;429 超出频率限制;422 或 500 请求未能处理(请先查看 msg、检查参数,再决定是否重试)。 可选值:200 / 401 / 402 / 404 / 422 / 429 / 433 / 455 / 500 / 501 / 505。 示例:200。
msgstring是响应消息,失败时的错误描述
dataobject是—
  data.taskIdstring是可以使用任务 ID 与“获取任务详细信息”端点一起查询任务状态。
json
{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "task_gpt-image_1765968156336"
  }
}

回调 ​

onImageGenerated ​

回调地址:{$request.body#/callBackUrl}(即请求体里的 callBackUrl)。

任务成功或失败时发送回调。

回调体参数

参数类型必填说明
codeinteger否200:成功;501:失败,原因见 data.failCode 与 data.failMsg。 可选值:200 / 501。 示例:200。
msgstring否状态消息 示例:Playground task completed successfully.。
dataobject否—
  data.completeTimeinteger否任务完成时间,Unix 毫秒时间戳 示例:1786432473000。
  data.costTimeinteger否处理耗时(秒),成功和失败回调都会返回。 示例:76。
  data.createTimeinteger否任务创建时间,Unix 毫秒时间戳 示例:1786432397000。
  data.creditsConsumednumber否本任务消耗的积分;失败任务为 0。 示例:4。
  data.modelstring否图片编辑使用的模型 示例:gpt-image/1.5-image-to-image。
  data.paramstring否创建任务时提交的参数,JSON 字符串格式 示例:{"input":"{\"aspect_ratio\":\"3:2\",\"prompt\":\"使用提供的服装图像为女性形象进行编辑,保持其面部特征、表情、发型和比例的精确还原。仅替换服装部分,使衣物自然贴合她的现有姿势和身体结构,并具备逼真的布料质感。调整光照、阴影和色温,使其与原始照片一致,实现高度逼真的融合效果,避免看起来像是直接粘贴上去。\",\"input_urls\":[\"https://static.aiquickdraw.com/tools/example/1765962794374_GhtqB9oX.webp\"],\"quality\":\"medium\"}","callBackUrl":"https://your-domain.com/api/callback","model":"gpt-image/1.5-image-to-image"}。
  data.resultJsonstring否图片生成结果,JSON 字符串格式。resultUrls 为生成图片的 URL 列表。仅在 state 为 success 时出现。 示例:{"resultUrls":["https://tempfile.aiquickdraw.com/images/chatgpt/file_00000000a2ec81f7824e0c47380c4e2e.png"]}。
  data.statestring否任务状态 可选值:success / fail。 示例:success。
  data.taskIdstring否任务 ID 示例:4365c9c9261f1623f40e86acf09da76d。
  data.updateTimeinteger否完成时间请以 completeTime 为准;updateTime 可能与 createTime 相同。 示例:1786432473000。
  data.failCodestring否失败码,数字字符串,如 "400"、"500"。仅在 state 为 fail 时出现。 示例:500。
  data.failMsgstring否失败原因,仅在 state 为 fail 时出现。 示例:&lt;error detail&gt;。

成功

json
{
  "code": 200,
  "msg": "Playground task completed successfully.",
  "data": {
    "taskId": "4365c9c9261f1623f40e86acf09da76d",
    "model": "gpt-image/1.5-image-to-image",
    "state": "success",
    "param": "{\"input\":\"{\\\"aspect_ratio\\\":\\\"3:2\\\",\\\"prompt\\\":\\\"使用提供的服装图像为女性形象进行编辑,保持其面部特征、表情、发型和比例的精确还原。仅替换服装部分,使衣物自然贴合她的现有姿势和身体结构,并具备逼真的布料质感。调整光照、阴影和色温,使其与原始照片一致,实现高度逼真的融合效果,避免看起来像是直接粘贴上去。\\\",\\\"input_urls\\\":[\\\"https://static.aiquickdraw.com/tools/example/1765962794374_GhtqB9oX.webp\\\"],\\\"quality\\\":\\\"medium\\\"}\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"model\":\"gpt-image/1.5-image-to-image\"}",
    "resultJson": "{\"resultUrls\":[\"https://tempfile.aiquickdraw.com/images/chatgpt/file_00000000a2ec81f7824e0c47380c4e2e.png\"]}",
    "completeTime": 1786432473000,
    "createTime": 1786432397000,
    "costTime": 76,
    "creditsConsumed": 4,
    "updateTime": 1786432473000
  }
}

失败

json
{
  "code": 501,
  "msg": "Playground task failed.",
  "data": {
    "taskId": "4365c9c9261f1623f40e86acf09da76d",
    "model": "gpt-image/1.5-image-to-image",
    "state": "fail",
    "param": "{\"input\":\"{\\\"aspect_ratio\\\":\\\"3:2\\\",\\\"prompt\\\":\\\"使用提供的服装图像为女性形象进行编辑,保持其面部特征、表情、发型和比例的精确还原。仅替换服装部分,使衣物自然贴合她的现有姿势和身体结构,并具备逼真的布料质感。调整光照、阴影和色温,使其与原始照片一致,实现高度逼真的融合效果,避免看起来像是直接粘贴上去。\\\",\\\"input_urls\\\":[\\\"https://static.aiquickdraw.com/tools/example/1765962794374_GhtqB9oX.webp\\\"],\\\"quality\\\":\\\"medium\\\"}\",\"callBackUrl\":\"https://your-domain.com/api/callback\",\"model\":\"gpt-image/1.5-image-to-image\"}",
    "failCode": "500",
    "failMsg": "<error detail>",
    "completeTime": 1786432473000,
    "createTime": 1786432397000,
    "costTime": 76,
    "creditsConsumed": 0,
    "updateTime": 1786432473000
  }
}

ModelFold — 一个 API,接入所有主流 AI 模型。