POST
/
api
/
v1
/
flux
/
kontext
/
generate
Generate or Edit Image
curl --request POST \
  --url https://api.kie.ai/api/v1/flux/kontext/generate \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "prompt": "A serene mountain landscape at sunset with a lake reflecting the orange sky",
  "enableTranslation": true,
  "aspectRatio": "16:9",
  "outputFormat": "jpeg",
  "promptUpsampling": false,
  "model": "flux-kontext-pro"
}'
{
  "code": 200,
  "msg": "success",
  "data": {
    "taskId": "task12345"
  }
}

Usage Modes

  1. Text-to-Image Generation
    • Provide prompt and aspectRatio
    • Model will generate a new image based on the text description
  2. Image Editing
    • Provide prompt and inputImage
    • You can optionally provide an aspectRatio.
      • If supplied, the output will be cropped or padded to match this ratio.
      • If omitted, the original image’s ratio will be preserved.
    • Model will edit the input image according to the prompt

Important Notes

  • Generated images will expire after 14 days
  • Prompts only support English
  • Choose the appropriate model based on your needs:
    • flux-kontext-pro: Standard model for most use cases
    • flux-kontext-max: Enhanced model for complex scenes

Authorizations

Authorization
string
header
required

All APIs require authentication via Bearer Token.

Get API Key:

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

Usage: Add to request header: Authorization: Bearer YOUR_API_KEY

Note:

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

Body

application/json

Response

200
application/json

Request successful

The response is of type object.