Generate your First Images

Now that you have your API key, you’re ready to generate your first images on Leonardo!

Follow this recipe to generate your first images:


The guide will recreate the following functionality in the Web UI via API.

Creating Prompt to generate a series of images with model and style specified

Creating Prompt to generate a series of images with model and style specified

Generating Images via API tester

Use the inbuilt tester from our API documentation to generate some images using the default example. Simply add in your API key and select Try It!.

Running on API tester in documentation

Running on API tester in documentation

Below is an example response.

Use the generationId for the Get a Single Generation in the next call for you to view the images. Below is an expected example response

📘

Tip

  • Use Webhooks to get notified in real time when your Images have completed generating.
  • View all the generations ever created from your account using the Get generations by user ID API call.

🚧

Heads up

API credit costs will vary depending on the image size, model and features such as Alchemy.

To help you plan ahead, check out our handy guide here. Want to avoid running low on credits? Consider setting up Auto-top up for peace of mind.

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 '
{
  "height": 512,
  "modelId": "6bef9f1b-29cb-40c7-b9df-32b51c1f67d3",
  "prompt": "An oil painting of a cat",
  "width": 512
}
'

Be sure to check out the Image Generation guides for more customisation options and how to use the right combination of parameters to get the result you're looking for.