Generate Images Using Flux

Follow this recipes to generate images using the Flux model.


The guide will recreate the following functionality in the Web UI via 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 '
{
  "modelId": "b2614463-296c-462a-9586-aafdb8f00e36",
  "contrast": 3.5,
  "prompt": "an orange cat playing with a tennis ball with the text FLUX",
  "num_images": 4,
  "width": 1472,
  "height": 832,
  "styleUUID": "111dc692-d470-4eec-b791-3475abac4c46",
  "enhancePrompt": false
}
'

Sample Output

Leonardo Phoenix with the prompt "an orange cat standing on a blue basketball with the text PAWS"

Flux Precision (Flux Dev) with the prompt "an orange cat playing with a tennis ball with the text FLUX"

Required Parameters

  • modelId

    PresetModelmodelId
    Flux SpeedFlux Schnell1dd50843-d653-4516-a8e3-f0238ee453ff
    Flux PrecisionFlux Devb2614463-296c-462a-9586-aafdb8f00e36
  • prompt - Text prompt to use for generation.

Supported Parameters

  • contrast

    ContrastValue
    Low3
    Medium3.5
    High4

    Accepts [1.0, 1.3, 1.8, 2.5, 3, 3.5, 4, 4.5].

  • enhancePrompt (Prompt Enhance)

    • Set to false for OFF.
    • Set to true for ON and specify enhancePromptInstruction: "INSTRUCTION_AS_STRING".
  • height - Height input resolution.

  • num_images - Number of images.

  • styleUUID (Preset Style)

    Preset StyleUUID
    3D Renderdebdf72a-91a4-467b-bf61-cc02bdeb69c6
    Acrylic3cbb655a-7ca4-463f-b697-8a03ad67327c
    Anime Generalb2a54a51-230b-4d4f-ad4e-8409bf58645f
    Creative6fedbf1f-4a17-45ec-84fb-92fe524a29ef
    Dynamic111dc692-d470-4eec-b791-3475abac4c46
    Fashion594c4a08-a522-4e0e-b7ff-e4dac4b6b622
    Game Concept09d2b5b5-d7c5-4c02-905d-9f84051640f4
    Graphic Design 3D7d7c2bc5-4b12-4ac3-81a9-630057e9e89f
    Illustration645e4195-f63d-4715-a3f2-3fb1e6eb8c70
    None556c1ee5-ec38-42e8-955a-1e82dad0ffa1
    Portrait8e2bc543-6ee2-45f9-bcd9-594b6ce84dcd
    Portrait Cinematic4edb03c9-8a26-4041-9d01-f85b5d4abd71
    Ray Tracedb504f83c-3326-4947-82e1-7fe9e839ec0f
    Stock Photo5bdc3f2a-1be6-4d1c-8e77-992a30824a2c
    Watercolor1db308ce-c7ad-4d10-96fd-592fa6b75cc4
  • ultra (Generation Mode - Ultra) - Set to true to turn on ultra.

  • width - Width input resolution.

Cost

Please refer to the apiCreditCost in the API response.