Leonardo AI started as a consumer image generation app and has since grown into something developers can build on, with its own models, a style control system called Elements, and an API you can call from code. Here is what the Leonardo AI API does, what it costs, and how to make your first generation call.
What the Leonardo AI API Is
The API gives you the same generation engine behind the Leonardo web app, reachable over plain web requests. It is billed separately from any consumer subscription you hold, on a pay-as-you-go basis, and it is aimed at developers and no-code builders who want to generate images from code rather than clicking through the interface. If the whole category is new to you, our complete AI image API guide covers the fundamentals first.
There are two versions, and the split matters. The original v1 is the broader of the two, supporting Alchemy rendering, PhotoReal, ControlNets (which let you steer composition or pose from a guide image), custom and fine-tuned models, and the Elements system. The newer v2 uses a simpler request format and is where Leonardo's current flagship models and several outside models live. Both are active, so check which version a model needs before building against it.
Key Features and Models
Lucid Origin, Phoenix 1.0, and Lucid Realism
Leonardo's own models include Lucid Origin, the most flexible of the three and the usual default for general work, Phoenix 1.0, its first model built from the ground up to follow prompts closely, and Lucid Realism, tuned for photographic output. Leonardo also passes requests through to outside models including Flux, Nano Banana, Seedream, GPT Image, and Ideogram, so one key reaches several engines rather than one account per vendor.
Elements and style control
Elements is Leonardo's way of holding a style or a character steady across generations, similar in spirit to training a small add-on that bakes a specific look into a model. You can use ones the community has made or build your own, then apply the same look across a whole batch. The v2 endpoint pushes this further by letting you pass separate reference images for style, content, character, and image-to-image, rather than lumping them together. Our guide to keeping AI-generated characters consistent compares how this is handled across models, and our walkthrough on using reference images covers getting good results from them.
Upscaling and editing
Beyond text-to-image, the API takes image uploads for image-to-image work and offers Pro Upscaler in precise and creative modes, unzoom, which pulls the frame back to reveal more of a scene than the original showed, and Canvas editing. If editing is the main thing you need rather than generating from scratch, our AI image editing API guide compares the options. Leonardo has also added video, 3D, and audio generation, which sit outside the core image API and are priced separately. Our AI video API guide covers that side of things.
Pricing
Leonardo has been moving its API away from subscriptions toward pay as you go. You load a dollar balance and each generation draws down an amount set by the model and your settings: resolution, how many images you asked for, and whether Alchemy is switched on. There is no flat per-image rate published, because the cost genuinely varies that much. Instead the dashboard has a calculator for estimating a batch before you run it, and every generation response comes back with a cost figure attached so you can track spending as it happens. For what other providers charge, see our breakdown of AI image API pricing in 2026.
Be honest with yourself about whether that suits you. A calculator and a cost field on each response are useful once you are running, but they do not help you compare Leonardo against a provider that simply says six cents an image before you write any code. If predictable per-image cost is what you need for a budget or a customer quote, a provider with a flat published rate is easier to work with, and our comparison of the main image APIs lists those side by side.
New API accounts start with $5 in free credit, and that balance does not expire, which is more generous than most trial credits that vanish after a month. When it runs out, requests stop until you top up. Pay as you go also allows up to 10 generations running at once and includes remove.bg background removal. Budgeting takes a little more attention than a flat plan, but you only pay for what you generate.
Getting Access
- Create an account or log in at app.leonardo.ai.
- Open API Access in the left menu and add credit to your API balance. This is a separate pot from any consumer plan you already pay for, and credits do not move between the two.
- Click Create New Key and name it. You can also set an address on your own server for Leonardo to send the result to automatically, which saves you repeatedly asking whether the job has finished.
- Send an
authorization: Bearer YOUR_API_KEYheader on every request.
No waitlist and no approval step. Sign-up is self-serve, and one account can hold up to 10 keys.
Your First Generation Call
Generation runs in the background. You submit a prompt, get an ID back, then either ask for the result on a loop or let Leonardo call your server when it is done. Here is the loop version in Python on the v1 endpoint.
import os
import time
import requests
API_KEY = os.environ["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 ID 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")Two things to watch in that example. It asks for four images, and since Leonardo bills per image generated rather than per request, that call costs four times a single one. Drop num_images to 1 while you are testing prompt wording. Alchemy is also switched on, which raises the cost again, so leave it off until you are generating something you intend to keep. The key is read from an environment variable rather than pasted into the file, which keeps it out of your version history.
A note on the modelId field: on v1 it must be the model's long identifier string, not a readable name. Call GET /platformModels first to see what is currently available and grab the right one, since the list changes as models are added and retired. The v2 endpoint is friendlier here: it takes a readable name such as lucid-origin or phoenix-v1.0 in a model field, with the rest of the settings nested under parameters. If you are starting fresh and your models are on v2, start there.
How It Compares
Midjourney publishes no general developer API, so calling it from code means going through a third-party platform rather than straight to the source. Leonardo is the more direct choice if you want a documented API from the company that makes the model. Our complete Midjourney prompt guide covers the app workflow if that is the route you prefer, and our roundup of the best Midjourney API alternatives looks at what teams use instead.
Stability AI and Black Forest Labs, the team behind Flux, both publish plain per-image rates, which makes cost easier to predict than Leonardo's calculator. Our Stable Diffusion API guide walks through that pricing, and our Flux vs Stable Diffusion vs Midjourney comparison sets the three against each other. What Leonardo offers in return is breadth behind one key, since it carries its own models alongside Flux, Nano Banana, Seedream, and others, plus a more developed toolkit for style consistency through Elements.
Worth being clear on one point: Leonardo's own models are not available through Apiframe, so if Lucid Origin or Elements is what you want, go to Leonardo directly. Where a platform carrying many models helps is if Leonardo is one piece of a bigger picture and you also need video from Kling or Runway, or music, without running a separate account and bill for each. Our guide to unified APIs works through when that trade is worth making and when it is not.
FAQ
Is there a free Leonardo AI API tier?
New accounts get $5 in starter credit that never expires, but there is no ongoing free tier for production. Once it runs out you need to fund the balance. Our guide to what is actually free in AI image generation APIs covers which providers give you more to work with.
How is pricing calculated?
Pay as you go, drawn from your balance. Cost depends on the model, resolution, how many images you request, and extras like Alchemy. Leonardo gives you a calculator and returns a cost figure with each response rather than publishing one rate per image. Requesting four images costs four times requesting one, which is the easiest way to burn through the starter credit without noticing.
Can I fine-tune or use custom styles through the API?
Yes. The v1 endpoint supports custom and fine-tuned models along with Elements for style and character consistency, and v2 extends this with separate references for style, content, and character.
Should I build on v1 or v2?
Check which version carries the model you want before deciding, since that usually settles it. v2 has the simpler request format, readable model names, and the newer flagship models. v1 still has the wider feature set, including ControlNets and fine-tuned models. Both are live, so this is not a case of one replacing the other yet.
Is it suitable for commercial use?
Yes. The API is built for production use under terms separate from the consumer app, so read Leonardo's current terms for specifics on usage rights before shipping. If generated images will be seen by your customers, our guide to AI content moderation covers the checks worth adding. Comparing Leonardo against the rest of the field? Our 9 best AI image generator APIs for developers roundup puts the main options side by side, and the complete AI image API guide is the place to start if you want the general picture first. If you need image, video, and music models behind a single key, our getting started guide covers setting that up with 100 free credits, though Leonardo's own models are not part of that catalog.