Skip to main content
POST
/
api
/
v1
/
jobs
/
createTask
使用 flux-2/flex-text-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": "flux-2/flex-text-to-image",
  "callBackUrl": "https://your-domain.com/api/callback",
  "input": {
    "prompt": "A humanoid figure with a vintage television set for a head, featuring a green-tinted screen displaying a `Hello FLUX.2` writing in ASCII font. The figure is wearing a yellow raincoat, and there are various wires and components attached to the television. The background is cloudy and indistinct, suggesting an outdoor setting",
    "aspect_ratio": "1:1",
    "resolution": "1K"
  }
}
'
{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "task_flux-2_1765175490366"
  }
}

Query Task Status

After submitting a task, use the unified query endpoint to check progress and retrieve results:

Get Task Details

Learn how to query task status and retrieve generation results
For production use, we recommend using the callBackUrl parameter to receive automatic notifications when generation completes, rather than polling the status endpoint.

Authorizations

Authorization
string
header
required

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

获取 API Key:

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

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

注意事项:

  • 请妥善保管您的 API Key,切勿泄露给他人
  • 若怀疑 API Key 泄露,请立即在管理页面重置

Body

application/json
model
enum<string>
default:flux-2/flex-text-to-image
required

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

  • 该端点必须使用 flux-2/flex-text-to-image 模型
Available options:
flux-2/flex-text-to-image
Example:

"flux-2/flex-text-to-image"

callBackUrl
string<uri>

接收生成任务完成通知的回调 URL。可选配置,建议在生产环境中使用。

  • 任务生成完成后,系统会向该 URL POST 任务状态与结果
  • 回调内容包含生成的资源 URL 与任务相关信息
  • 您的回调端点需要支持接收带 JSON 负载的 POST 请求
  • 也可以选择调用任务详情端点,主动轮询任务状态
Example:

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

input
object

生成任务的输入参数

Response

请求成功

code
enum<integer>

响应状态码

  • 200: 成功 - 请求已处理完成
  • 401: 未授权 - 身份验证凭据缺失或无效
  • 402: 积分不足 - 账户积分不足以执行该操作
  • 404: 未找到 - 请求的资源或端点不存在
  • 422: 验证错误 - 请求参数未通过校验
  • 429: 速率限制 - 已超出该资源的请求频次限制
  • 455: 服务不可用 - 系统正在维护中
  • 500: 服务器错误 - 处理请求时发生意外故障
  • 501: 生成失败 - 内容生成任务执行失败
  • 505: 功能禁用 - 当前请求的功能暂未开放
Available options:
200,
401,
402,
404,
422,
429,
455,
500,
501,
505
msg
string

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

Example:

"success"

data
object