跳转到主要内容
POST
/
api
/
v1
/
jobs
/
createTask
使用 grok-imagine/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": "grok-imagine/image-to-image",
  "callBackUrl": "https://your-domain.com/api/callback",
  "input": {
    "prompt": "Recreate the Titanic movie poster with two adorable anthropomorphic cats in the same romantic pose at the bow of the ship. The male cat is an orange tabby wearing a vest, standing behind a white long-haired female cat in a lace dress, holding her paws as they stretch forward in the wind. Both cats are photorealistic with detailed fur, wind-swept hair, and dramatic sunset lighting (warm golden highlights, cool blue shadows). Background: the Titanic ship at dusk with four smokestacks, glowing deck lights, calm ocean, and orange-pink sunset sky. Center title: \"CATANIC\" in the same gold metallic serif style as Titanic, same size and position.",
    "image_urls": [
      "https://static.aiquickdraw.com/tools/example/1767602105243_0MmMCrwq.png"
    ]
  }
}
'
{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "task_grok-imagine_1767694553297"
  }
}

文件上传要求

在使用图像到图像 API 之前,您需要上传您的参考图像:
1

上传参考图像

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

文件上传 API

了解如何上传图像并获取文件 URL
要求:
  • 文件类型:JPEG、PNG 或 WebP 格式
  • 最大文件大小:每个文件 10MB
  • 内容:您想要用作生成参考的图像
2

获取文件 URL

上传后,您将收到可在 image_urls 参数中使用的文件 URL。
  • 支持的格式:JPEG、PNG、WebP(最大:10MB)
  • 每个请求最多一个图像

查询任务状态

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

获取任务详情

了解如何查询任务状态并获取生成结果
对于生产环境,我们建议使用 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>
默认值:grok-imagine/image-to-image
必填

用于生成任务的模型名称。必填字段。

  • 此端点必须为 grok-imagine/image-to-image
可用选项:
grok-imagine/image-to-image
示例:

"grok-imagine/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