FLUX.2 Pro

This guide shows how to generate images using FLUX.2 Pro model via the Leonardo.AI REST API.

Sample Request

curl --location 'https://cloud.leonardo.ai/api/rest/v2/generations' \
     --header 'authorization: Bearer {api-key}' \
     --header 'Content-Type: application/json' \
     --data '{
       "public": false,
       "model": "flux-pro-2.0",
       "parameters": {
           "prompt": "A cat wearing a hat",
           "quantity": 1,
           "width": 1440,
           "height": 1440,
           "seed": 4294967295,
           "guidances": {
               "image_reference": [
                  {
                      "image": {
                          "id": "fc6f78c6-e7ac-491b-ad26-01f6843db870",
                          "type": "GENERATED"
                      },
                      "strength": "MID"
                  },
                  {
                      "image": {
                          "id": "a8e374dd-52f8-4236-ad9e-99b1f601fa3a",
                          "type": "UPLOADED"
                      },
                      "strength": "MID"
                  }
              ]
           }
        }
      }'

Recipe

API Request Endpoint, Headers, Parameters (FLUX.2 Pro)

Endpoint

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

Headers

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

Body Parameters

ParameterTypeDefinition
guidancesobjectOptional. Object defining image guidance inputs that influence the generated result.
guidances.image_referencearrayOptional. Array of up to 4 reference images. Each reference includes image.id, image.type (GENERATED or UPLOADED), and strength (LOW, MID, HIGH).
heightintegerOptional. Height input resolution. Supports 256 to 1440.
modelstringRequired. Model identifier. Set to flux-pro-2.0
promptstringRequired. Text prompt describing what image you want the model to generate.
prompt_enhancestringOptional. Enables prompt enhancement when set to "ON"; disabled when set to "OFF".
publicbooleanOptional. Boolean flag that determines whether the generation is public (true) or private (false).
quantityintegerOptional. Number of images to generate in a single request. Default is 1, maximum is 8.
seedintegerOptional. Apply a fixed seed to maintain consistency across generation sets. The maximum seed value is 4294967295 for Flux.
style_idsarrayOptional. Array of style UUIDs used to apply preset artistic styles to the output.
widthintegerOptional. Width input resolution. Supports 256 to 1440.

Aspect Ratio Settings

Aspect RatioWidthHeight
2:39601440
1:114401440
16:91440810
9:168101440