Recraft V4.1

This guide shows how to generate images using the Recraft V4.1 model via the Leonardo.AI REST API. #

Sample Request

curl --request POST \
     --url https://cloud.leonardo.ai/api/rest/v2/generations \
     --header 'accept: application/json' \
     --header 'authorization: Bearer <YOUR_API_KEY>' \
     --header 'content-type: application/json' \
     --data '{
       "model": "recraft/recraft-4.1",
       "parameters": {
           "width": 1024,
           "height": 1024,
           "prompt": "Flat vector illustration of a koala wearing a purple wizard hat, riding a skateboard, clean lines, minimal shading",
           "quantity": 2,
           "prompt_enhance": "AUTO",
           "colors": ["#6B2FA3", "#F2C14E", "#3A3A3A"],
           "background_color": "#FFFFFF"
       },
       "public": false
   }'

API Request Endpoint, Headers, Parameters

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
background_colorstringOptional. Preferred background color for the image, as a #RRGGBB hex value. The model treats it as a hint.
colorsarrayOptional. Preferred color palette for the image, as up to 5 unique #RRGGBB hex values. The model treats them as a hint and may not use every color.
heightintegerOptional. Height input resolution. Supports 768, 832, 896, 1024, 1152, 1216, 1280, 1344, 1536, 1664, 1792, 2048, 2304, 2432, 2560, 2688, or 3072. The combinations 2688 × 1536 and 1536 × 2688 (width × height) are not supported. Defaults to 1024.
modelstringRequired. Model identifier. Set to recraft/recraft-4.1.
promptstringRequired. Text prompt describing what image you want the model to generate.
prompt_enhancestringOptional. Controls prompt enhancement. Supports AUTO, ON, or OFF. Defaults to AUTO.
publicbooleanOptional. Boolean flag that determines whether the generation is public (true) or private (false).
quantityintegerOptional. Number of images to generate in a single request. Supports 1 to 8. Defaults to 4.
widthintegerOptional. Width input resolution. Supports 768, 832, 896, 1024, 1152, 1216, 1280, 1344, 1536, 1664, 1792, 2048, 2304, 2432, 2560, 2688, or 3072. The combinations 2688 × 1536 and 1536 × 2688 (width × height) are not supported. Defaults to 1024.

Did this page help you?