Leonardo AI started as a consumer image generation app, but it has grown into a genuinely developer-friendly platform with its own models, a style control system called Elements, and a REST API that developers can plug into. If you want to know what the Leonardo AI API actually does, what it costs, and how to make your first image generation call, here is the full rundown.
What Is the Leonardo AI API
The Leonardo AI API exposes the same generation engine behind the Leonardo web app through a REST interface, but it runs on separate, pay-as-you-go billing from any consumer app subscription you might have. It is built for developers and no-code builders who want to generate images through code rather than through the web interface.
The API actually spans two endpoint generations. The original v1 endpoint is broad and supports Alchemy rendering, PhotoReal, ControlNets, custom and fine-tuned models, and Leonardo's Elements system. A newer v2 endpoint uses a cleaner schema and is where Leonardo's current flagship models and several third-party models it can pass requests to live. Both are still active, so it is worth checking which one a given model requires before you build against it.
Key Features and Models
Phoenix 1.0 and Lucid Realism
Leonardo's own flagship models include Phoenix 1.0, built for strong prompt adherence and versatility, and Lucid Realism, tuned more toward photorealistic output. On top of its own models, Leonardo also routes requests to a number of third-party models it can pass requests to, including Flux, Nano Banana, Seedream, GPT Image, and Ideogram, so you can access several image generation engines through one API key rather than integrating each separately.
Elements and style control
Elements is Leonardo's system for consistent style and character control, similar in spirit to LoRA-style fine-tuning (a technique for baking a specific visual style into the model). You can reference community Elements or your own to keep a consistent look across a batch of generations. The newer v2 endpoint builds on this idea with a more structured guidance system for style, content, character, and image-to-image references.
Upscaling and editing tools
Beyond straightforward text-to-image, the API supports image uploads for image-to-image work, Pro Upscaler tools in both precise and creative modes, unzoom, and Canvas-related editing operations. There are also newer additions for video, 3D generation, and audio, though those are separate product lines from the core image API.
Leonardo AI API Pricing
Leonardo runs the API on a pay-as-you-go model rather than a subscription. You fund an account balance in dollars, and each generation deducts an amount based on the model and settings you use, for example resolution, number of images, and whether Alchemy is enabled. Leonardo does not publish a flat per-image rate card for the API, since cost varies quite a bit by model and settings. Instead, they provide an API pricing calculator in the dashboard so you can estimate cost before running a batch of requests, and generation responses include a cost breakdown so you can track spend as you go.
New API accounts start with some free credit to test the API before committing any budget, and your balance does not expire, it just sits there until you use it or top it up again. If your balance hits zero, requests pause until you add more funds. This makes budgeting a bit more hands-on than a flat subscription, but it also means you only pay for what you actually generate.
How to Get API Access
- Create an account or log into app.leonardo.ai.
- Go to API Access in the left menu and add credit to your API balance. This is separate from any consumer web app plan you might already have.
- Click Create New Key and name it. You can also set an optional webhook URL (a server address where results get sent automatically) so you do not have to keep checking back for the result.
- Every request needs an
authorization: Bearer YOUR_API_KEYheader.
There is no waitlist or approval process. It is fully self-serve, and you can have up to ten active API keys on one account.
Code Example: Your First Image Generation Call
Leonardo's generation endpoint runs in the background: you submit a prompt, get back a generation ID, then either keep checking back for the result or use a webhook. Here is the check-back approach using Python.
import time
import requests
API_KEY = "YOUR_LEONARDO_API_KEY"
BASE_URL = "https://cloud.leonardo.ai/api/rest/v1"
HEADERS = {
"accept": "application/json",
"authorization": f"Bearer {API_KEY}",
"content-type": "application/json",
}
payload = {
"prompt": "A serene watercolor painting of a mountain lake at sunrise",
"modelId": "YOUR_MODEL_ID", # fetch a valid model UUID from GET /platformModels first
"width": 1024,
"height": 768,
"num_images": 4,
"alchemy": True,
}
resp = requests.post(f"{BASE_URL}/generations", json=payload, headers=HEADERS)
resp.raise_for_status()
generation_id = resp.json()["sdGenerationJob"]["generationId"]
while True:
r = requests.get(f"{BASE_URL}/generations/{generation_id}", headers=HEADERS)
data = r.json()["generations_by_pk"]
if data["status"] in ("COMPLETE", "FAILED"):
break
time.sleep(3)
if data["status"] == "COMPLETE":
for img in data["generated_images"]:
print(img["url"])
else:
print("Generation failed")A quick note on the modelId field: it needs to be a real model UUID, not a name. Call GET /platformModels first to see the current list of available models and their IDs, since these can change as Leonardo adds new models.
Leonardo AI API vs Alternatives
Midjourney does not have an official public API as of this writing, so anyone using Midjourney through code is going through an unofficial workaround that requires a paid subscription. That makes Leonardo a more straightforward choice if you specifically need a supported, documented API.
Stability AI and Black Forest Labs (the team behind Flux) both publish clear, credit-based per-image rate cards, which makes cost estimation simpler than Leonardo's calculator-based approach. What Leonardo offers in exchange is a broader single API surface, since it bundles its own models alongside Flux, Nano Banana, Seedream, and others, plus a more developed style consistency toolkit through Elements. If you want access to Leonardo's models alongside entirely different vendors like Kling or Runway for video without piecing together separate integrations, a unified API like Apiframe is worth a look, since it consolidates several image and video models behind one key.
FAQ
Is there a free Leonardo AI API tier?
New API accounts receive some free starter credit to test things out, but there is no ongoing free tier for production use. Once that credit runs out, you need to fund your account balance to keep generating.
How is Leonardo AI API pricing calculated?
It works on a pay-as-you-go basis, drawing from your account balance. Cost per generation depends on the model, resolution, number of images, and features like Alchemy. Leonardo provides a pricing calculator and returns a cost breakdown with each generation response rather than publishing one flat per-image rate.
Can I fine-tune or use custom styles via the API?
Yes. The v1 endpoint supports custom and fine-tuned models along with the Elements system for style and character consistency, and the newer v2 endpoint extends this with a structured guidance system.
Is the Leonardo AI API suitable for commercial use?
Yes, the API is designed for production use by developers building on top of Leonardo's models, separate from the consumer app's own licensing terms. Check Leonardo's current terms of service for specifics on usage rights before shipping a commercial product. Looking to compare Leonardo against other image generation APIs? Our 9 Best AI Image Generator APIs for Developers roundup puts the main options side by side, and our Flux vs Stable Diffusion vs Midjourney API guide focuses on the three most popular alternatives. If you want a broader introduction to how AI image APIs work, the AI Image API complete guide is a good place to start.