跳转到主要内容
POST
/
api
/
v1
/
jobs
/
createTask
使用 gpt-image/1.5-image-to-image 生成内容
curl --request POST \
  --url https://api.kie.ai/api/v1/jobs/createTask \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '
{
  "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"
  }
}
'
{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "task_gpt-image_1765968156336"
  }
}

概述

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

文件上传要求

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

上传图像

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

文件上传 API

了解如何上传图像并获取文件 URL
2

获取文件 URL

上传完成后,您将获得可在 input_urls 参数中使用的文件 URL。
  • 支持格式:JPEG、PNG、WebP
  • 最大文件大小:10MB
  • 每个请求最多16个输入 URL
  • 图像内容应适当并遵循使用指南

查询任务状态

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

获取任务详情

了解如何查询任务状态和检索生成结果
对于生产使用,我们建议使用 callBackUrl 参数接收生成完成时的自动通知,而不是轮询状态端点。

相关资源

授权

Authorization
string
header
必填

所有 API 都需要通过 Bearer Token 进行身份验证。

获取 API Key:

  1. 访问 API Key 管理页面 获取您的 API Key

使用方法: 添加到请求头: Authorization: Bearer YOUR_API_KEY

注意:

  • 请妥善保管您的 API Key,不要与他人共享
  • 如果您怀疑 API Key 已泄露,请立即在管理页面重置

请求体

application/json
model
enum<string>
默认值: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"

callBackUrl
string<uri>

接收生成任务完成更新的 URL。可选但建议在生产环境中使用。

  • 当生成完成时,系统将向此 URL POST 任务状态和结果
  • 回调包含生成的内容 URL 和任务信息
  • 您的回调端点应接受包含结果的 JSON 负载的 POST 请求
  • 或者,使用获取任务详情端点轮询任务状态
示例:

"https://your-domain.com/api/callback"

input
object

生成任务的输入参数

响应

请求成功

code
enum<integer>

响应状态码

  • 200: 成功 - 请求已成功处理
  • 401: 未授权 - 身份验证凭据缺失或无效
  • 402: 积分不足 - 账户没有足够的积分执行操作
  • 404: 未找到 - 请求的资源或端点不存在
  • 422: 验证错误 - 请求参数未通过验证检查
  • 429: 速率限制 - 已超过此资源的请求限制
  • 455: 服务不可用 - 系统正在维护中
  • 500: 服务器错误 - 处理请求时发生意外错误
  • 501: 生成失败 - 图像生成任务失败
  • 505: 功能已禁用 - 请求的功能当前已禁用
可用选项:
200,
401,
402,
404,
422,
429,
455,
500,
501,
505
msg
string

响应消息,失败时为错误描述

示例:

"success"

data
object