Skip to main content
POST
/
api
/
v1
/
jobs
/
createTask
Generate image using 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

All APIs require authentication via Bearer Token.

Get API Key:

  1. Visit the API Key Management Page to get your API Key

Usage: Add to request headers: Authorization: Bearer YOUR_API_KEY

Notes:

  • Keep your API Key secure and do not share it with others
  • If you suspect your API Key has been compromised, reset it immediately on the management page

Body

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

Model name for the generation task. Required field.

  • This endpoint must use the flux-2/flex-text-to-image model
Available options:
flux-2/flex-text-to-image
Example:

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

callBackUrl
string<uri>

Callback URL to receive notifications when the generation task is completed. Optional configuration, recommended for production environments.

  • After the task is generated, the system will POST task status and results to this URL
  • The callback content includes the generated resource URL and task-related information
  • Your callback endpoint needs to support receiving POST requests with JSON payloads
  • Alternatively, you can call the task details endpoint to actively poll task status
Example:

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

input
object

Input parameters for the generation task

Response

Request successful

code
enum<integer>

Response status code

  • 200: Success - Request has been processed successfully
  • 401: Unauthorized - Authentication credentials are missing or invalid
  • 402: Insufficient Credits - Account credits are insufficient to perform this operation
  • 404: Not Found - The requested resource or endpoint does not exist
  • 422: Validation Error - Request parameters failed validation
  • 429: Rate Limit - Request frequency limit for this resource has been exceeded
  • 455: Service Unavailable - System is under maintenance
  • 500: Server Error - An unexpected error occurred while processing the request
  • 501: Generation Failed - Content generation task execution failed
  • 505: Feature Disabled - The requested feature is currently unavailable
Available options:
200,
401,
402,
404,
422,
429,
455,
500,
501,
505
msg
string

Response message, error description when request fails

Example:

"success"

data
object