Recraft V4

This guide shows how to generate images using the Recraft V4 model via the Leonardo.AI Production 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": "recraft-v4",
    "parameters": {
      	"prompt": "A kangaroo eating pizza on a beach",
      	"prompt_enhance": "OFF",
      	"quantity": 2,
      	"width": 1024,
      	"height": 1024
    }
  }'

Recipe


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
modelstringRequired. Set to recraft-v4.
publicbooleanOptional. Whether the generation is publicly visible. Use false for private generations.
parameters.promptstringRequired. Text prompt describing the desired image.
parameters.prompt_enhancestringOptional. "ON" or "OFF".
parameters.quantityintegerOptional. Number of images per request: 1–6; for more than 6 images, send multiple requests.
parameters.widthintegerRequired. Must match one of the fixed resolutions below for the chosen aspect ratio (see table below).
parameters.heightintegerRequired. Must match one of the fixed resolutions below for the chosen aspect ratio (see table below).

Aspect Ratio Settings

Use exactly these sizes for Recraft V4. Custom resolutions are not supported.

Aspect RatioWidthHeight
1:110241024
2:11536768
1:27681536
3:21280832
2:38321280
4:31216896
3:48961216
5:41152896
4:58961152
6:108321344
14:101280896
10:148961280
16:91344768
9:167681344