Generate Images Using GPT1.5

Follow this recipes to generate images using the GPT1.5 model.


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": "gpt-image-1.5",
  "parameters": {
    "mode": "QUALITY",
    "prompt": "Koala with purple hat",
    "quantity": 2,
    "width": 1024,
    "height": 1024,
    "seed": 4294967295,
    "guidances": {
      "image_reference": [
        {
          "image": {
            "id": "00000000-0000-0000-0000-000000000001",
            "type": "UPLOADED"
          },
          "strength": 0.5,
          "prompt_enhance": "OFF"
        }
      ]
    }
  }
}
'

Parameters

  • model - Set to gpt-image-1.5
  • height - Supports 1024 and 1536
  • width - Supports 1024 and 1536
  • quantity - Number of images generated
  • mode - FAST, QUALITY, ULTRA
  • guidances.image_reference - List of image references up to 6. Supports uploaded images and images generated on the Leonardo platform.
  • seed - Randomisation parameter.

Aspect Ratio Settings

Aspect RatioWidthHeight
2:310241536
1:110241024
3:215361024

Cost

Pricing is a function of the base cost, input height, input width, quantity, mode and whether or not image references were used. Refer to the calculation below to get the API credit cost based on your settings.

Cost = Base * Height * Width * Quantity * Mode * Image Reference

Base = 0.0000123977

Parameter

Multiplier

Height

The height setting itself.

Width

The width setting itself.

Quantity

The quantity setting itself.

Mode

1 if set to FAST
2.92 if set to QUALITY
10.538 if set to ULTRA

Image Reference

1 if there are no image references
1.2 if at least one image reference is used

For example, assuming following settings:

{
  "public": false,
  "model": "gpt-image-1.5",
  "parameters": {
    "mode": "QUALITY",
    "prompt": "Koala with purple hat",
    "quantity": 2,
    "width": 1024,
    "height": 1024,
    "seed": 4294967295,
    "guidances": {
      "image_reference": [
        {
          "image": {
            "id": "00000000-0000-0000-0000-000000000001",
            "type": "UPLOADED"
          },
          "strength": 0.5,
          "prompt_enhance": "OFF"
        }
      ]
    }
  }
}

Cost = 0.0000123977 * 1024 * 1024 * 2 * 2.92 * 1.2 = 92 API Credits (Rounded up to the nearest credit.)