Generate Images Using Transparency
The Transparency feature enables you to generate images with a transparent background.
This guide recreates the following Transparency setting in the Leonardo Web App via API.
Sample Request
This request will generated an image without a background.
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 '
{
"alchemy": false,
"prompt": "an orange cat",
"width": 512,
"height": 512,
"modelId": "aa77f04e-3eec-4034-9c07-d0f619684628",
"transparency": "foreground_only",
"elements": [
{
"akUUID": "5f3e58d8-7af3-4d5b-92e3-a3d04b9a3414",
"weight": 0.5
}
]
}
'
"transparency": "foreground_only"
- Enables the transparency foreground only feature. The foreground image will be generated and the background will be removed."modelId": "aa77f04e-3eec-4034-9c07-d0f619684628"
- Sets the model to Leonardo Kino XL, one of the compatible models to transparency feature."elements.[0].akUUID": "5f3e58d8-7af3-4d5b-92e3-a3d04b9a3414"
- Sets the element to Simple Flat Illustration, one of the compatible elements to transparency feature.
Tip
To learn more about the recommended models and elements, please refer to the compatibility list.
Sample Output
Below is a sample output corresponding the the sample request above where transparency is set to foreground_only. The output generated is a PNG file with no background.
Updated 9 months ago