Generate Images Using Leonardo FLUX.1 Kontext [pro]
Generate Image from Text Prompts
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 '
{
"prompt": "a portrait-style photograph featuring a koala sitting against a neutral beige background. The koala has soft, fluffy gray fur with a lighter patch on its chest and around its nose. Its ears are large and fluffy, adding to its endearing look. The lighting is soft, highlighting the texture of the fur. The overall composition is centered, with the koala directly facing the camera, creating a charming and engaging image.",
"modelId": "28aeddf8-bd19-4803-80fc-79602d1a9989",
"styleUUID": "111dc692-d470-4eec-b791-3475abac4c46",
"num_images": 1,
"width": 832,
"height": 1248
}
Number Of Images
FLUX.1 Kontext [pro] can only generate 1 image at a time, make sure to have
"num_images":1
specified
Sample Output
![FLUX.1 Kontext [pro] with the prompt "a portrait-style photograph featuring a koala sitting against a neutral beige background. The koala has soft, fluffy gray fur with a lighter patch on its chest and around its nose. Its ears are large and fluffy, adding to its endearing look. The lighting is soft, highlighting the texture of the fur. The overall composition is centered, with the koala directly facing the camera, creating a charming and engaging image](https://files.readme.io/2b47a6b5f36cf87feb3c9df2ce0dac7f638080abb52885aab0ef6668186869b3-Default_a_portraitstyle_photograph_featuring_a_koala_sitting_a_0.jpg)
FLUX.1 Kontext [pro] with the prompt "a portrait-style photograph featuring a koala sitting against a neutral beige background. The koala has soft, fluffy gray fur with a lighter patch on its chest and around its nose. Its ears are large and fluffy, adding to its endearing look. The lighting is soft, highlighting the texture of the fur. The overall composition is centered, with the koala directly facing the camera, creating a charming and engaging image"
Generate from Image Reference with Generated Image
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": "This koala is wearing a white sunglasses",
"modelId": "28aeddf8-bd19-4803-80fc-79602d1a9989",
"styleUUID": "111dc692-d470-4eec-b791-3475abac4c46",
"num_images": 1,
"width": 832,
"height": 1248,
"contextImages": [{
"type": "GENERATED",
"id": "0e53510d-e321-411f-b0dc-9cdb63ca1732"
}]
}
Input Image

Sample Output
![FLUX.1 Kontext [pro] with the prompt "This koala is wearing a white sunglasses](https://files.readme.io/765518ebda19d58e9ff387e53707f206413bfbd2eda43d9e91c3c1ad2d93ead3-Default_This_koala_is_wearing_a_white_sunglasses_0.jpg)
FLUX.1 Kontext [pro] with the prompt "This koala is wearing a white sunglasses"
Generate from Image Reference with Uploaded Image
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"
}]
}
Input Uploaded Image

Sample Output
![FLUX.1 Kontext [pro] with the prompt "a kangaroo wearing a scarf"](https://files.readme.io/4a23497bfaa03b305819bd17c3ac2efacdba464939110a450881cb3b404dc4bc-Default_a_kangaroo_wearing_a_scarf_0.jpg)
FLUX.1 Kontext [pro] with the prompt "a kangaroo wearing a scarf"
Required Parameters
-
modelId
Model Model ID FLUX.1 Kontext [pro] 28aeddf8-bd19-4803-80fc-79602d1a9989 -
prompt - Text prompt to use for generation.
Supported Parameters
-
enhancePrompt (Prompt Enhance)
- For OFF, set to false.
- For ON, set to true and do not specify enhancePromptInstruction.
- For Edit with AI, set to true and specify
enhancePromptInstruction: "INSTRUCTION_AS_STRING"
.
-
height - Height input resolution. FLUX.1 Kontext [pro] only accept 672, 720, 752, 832, 880, 944, 1024, 1104, 1184, 1248, 1392, 1456, 1568.
-
num_images - Number of images, FLUX.1 Kontext [pro] only allow you to generate 1 image at a time.
-
styleUUID (Preset Style)
Preset Style UUID 3D Render debdf72a-91a4-467b-bf61-cc02bdeb69c6 Acrylic 3cbb655a-7ca4-463f-b697-8a03ad67327c Creative 6fedbf1f-4a17-45ec-84fb-92fe524a29ef Dynamic 111dc692-d470-4eec-b791-3475abac4c46 Fashion 594c4a08-a522-4e0e-b7ff-e4dac4b6b622 Game Concept 09d2b5b5-d7c5-4c02-905d-9f84051640f4 Graphic Design 2D 703d6fe5-7f1c-4a9e-8da0-5331f214d5cf Graphic Design 3D 7d7c2bc5-4b12-4ac3-81a9-630057e9e89f Illustration 645e4195-f63d-4715-a3f2-3fb1e6eb8c70 None 556c1ee5-ec38-42e8-955a-1e82dad0ffa1 Portrait 8e2bc543-6ee2-45f9-bcd9-594b6ce84dcd Portrait Cinematic 4edb03c9-8a26-4041-9d01-f85b5d4abd71 Portrait Fashion 0d34f8e1-46d4-428f-8ddd-4b11811fa7c9 Pro B&W photography 22a9a7d2-2166-4d86-80ff-22e2643adbcf Pro Color Photography 7c3f932b-a572-47cb-9b9b-f20211e63b5b Pro Film Photography 581ba6d6-5aac-4492-bebe-54c424a0d46e Ray Traced b504f83c-3326-4947-82e1-7fe9e839ec0f Stock Photo 5bdc3f2a-1be6-4d1c-8e77-992a30824a2c Watercolor 1db308ce-c7ad-4d10-96fd-592fa6b75cc4
- width - Width input resolution. FLUX.1 Kontext [pro] only accept 672, 720, 752, 832, 880, 944, 1024, 1104, 1184, 1248, 1392, 1456, 1568.
- type - Source of the image, GENERATED or UPLOADED
- id - The image UUID returned by the upload or by generation.
Note
If using the
seed
parameter, the maximum seed number is2147483638
.
Cost
The FLUX.1 Kontext [pro] costs 50 API Credits per image.
Updated 3 days ago