FLUX.1 Kontext [pro]

This guide shows how to generate images using FLUX.1 Kontext [pro] model via the Leonardo.AI REST API.

This guide shows how to generate images using FLUX.1 Kontext [pro] model via the Leonardo.AI REST API.

Sample Request

curl --request POST \
     --url https://cloud.leonardo.ai/api/rest/v1/generations \
     --header 'accept: application/json' \
     --header 'authorization: Bearer <YOUR_API_KEY>' \
     --header 'content-type: application/json' \
     --data '{
       "prompt": "a kangaroo wearing a scarf",
       "modelId": "28aeddf8-bd19-4803-80fc-79602d1a9989",
       "styleUUID": "111dc692-d470-4eec-b791-3475abac4c46",
       "num_images": 1,
       "width": 832,
       "height": 1248,
       "contextImages": [{
           "type": "UPLOADED",
           "id": "0edab5a7-2efe-49b4-9283-7c79dd642981"
       }]
     }'

Recipe

API Request Endpoint, Headers, Parameters

Endpoint

https://cloud.leonardo.ai/api/rest/v1/generations

Headers

--header "accept: application/json" \
--header "authorization: Bearer <YOUR_API_KEY>" \
--header "content-type: application/json"

Body Parameters

ParameterTypeDefinition
contrastnumberRequired. Controls the contrast/detail level of generated images. Valid values: [3, 3.5, 4] where 3 corresponds to Low, 3.5 corresponds to Medium, and 4 corresponds to High in the web UI.
contextImagesarrayOptional. Array of up to 4 context images. Each context includes id (the image ID) and type (GENERATED or UPLOADED).
enhancePromptstringOptional. Enables prompt enhancement. Set to true for enhanced prompt behavior; when paired with enhancePromptInstruction it refines the prompt further.
enhancePromptInstructionstringOptional. Provides additional instruction used alongside enhancePrompt=true.
heightintegerOptional. Height input resolution.
modelIdstringRequired. UUID of the model to use. Set to 28aeddf8-bd19-4803-80fc-79602d1a9989.
num_imagesintegerOptional. Number of images to generate in the batch.
promptstringRequired. Text prompt describing what image you want the model to generate.
seedintegerOptional. Apply a fixed seed to maintain consistency across generation sets. The maximum seed number is 2147483638.
styleUUIDstringOptional. UUID of a preset style that affects the aesthetic output. Refer to the table below for a list of UUIDs.
ultrabooleanOptional. When true, enables Ultra generation mode.
widthintegerOptional. Width input resolution.