How to Get a Leonardo.Ai API Key: A Step-by-Step Guide
On this page
This guide shows you how to get a Leonardo.Ai API key. You'll create a Leonardo.Ai account, generate your key, and make your first API call, plus a free alternative for adding Leonardo.Ai models to your web app.
Prerequisites
- A Google, Canva, or email account, Leonardo.Ai supports multiple sign-in methods
- A valid payment method for verification (you'll receive $5 in free API credits)
- Basic familiarity with code (we'll show simple examples)
Step 1: Create Your Leonardo.Ai Account
Go to app.leonardo.ai/api-access. You'll see the sign-up/login page.
You can sign up using various methods including Canva, Google, or email. Once you've completed the setup and signed in, you'll land on the dashboard.
Note that Leonardo.Ai requires you to provide a valid payment method as verification. Once verified, you'll receive $5 in free API credits to get started.
Step 2: Open the API Keys Page
From the dashboard, open the API Keys page from the sidebar.
Step 3: Generate Your API Key
Inside the API Keys page, click the + Create New Key button.
Provide a name for your API key and an optional webhook URL.
Important: Copy the key immediately. Leonardo.Ai only shows it once. If you lose it, you'll need to generate a new one.
Store it somewhere safe, like a password manager, an .env file, or your platform's secrets manager. Never commit API keys to a public repository.
Step 4: Make Your First API Call
Leonardo.Ai uses a direct REST API for image generation. Here's a quick example using curl to generate an image:
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 '
{
"alchemy": false,
"height": 1080,
"modelId": "7b592283-e8a7-4c5a-9ba6-d18c31f258b9",
"contrast": 3.5,
"num_images": 4,
"styleUUID": "111dc692-d470-4eec-b791-3475abac4c46",
"prompt": "A serene watercolor painting of a mountain lake at sunrise",
"width": 1920,
"ultra": false
}
'
The response contains a generationId that you can use to fetch the generated images. For the full set of endpoints and parameters, see Leonardo.Ai's official API docs.
Can You Use the Leonardo.Ai API for Free?
Creating an API key is free, but generating images costs credits. Leonardo.Ai's API runs on a credit system, so each generation draws down a balance you pay for. After you add a payment method for verification, new accounts get free credits to start with. For current rates and credit packages, see Leonardo.Ai's pricing page.
Puter.js offers a different model. With its User-Pays model, you can add Leonardo.Ai models to your app for free: each user covers their own AI usage through their own Puter account, so your cost stays at $0 regardless of how many users you have, with no API key and no backend.
Add Leonardo.Ai models with the browser script tag:
<script src="https://js.puter.com/v2/"></script>
<script>
puter.ai.txt2img("A serene watercolor painting of a mountain lake at sunrise", {
model: "leonardoai/lucid-origin"
}).then(imageElement => {
document.body.appendChild(imageElement);
});
</script>
or the npm package:
import { puter } from '@heyputer/puter.js';
const imageElement = await puter.ai.txt2img("A serene watercolor painting of a mountain lake at sunrise", {
model: "leonardoai/lucid-origin"
});
document.body.appendChild(imageElement);
This fits front-end apps where your users sign into Puter: usage is tied to their accounts, and Puter.js runs in the browser, so it does not replace a server-side key for a backend you control.
Conclusion
To get a Leonardo.Ai API key: sign up at app.leonardo.ai/api-access, add a payment method for verification, then open the API Keys page and click + Create New Key. From there you can make your first image generation API call, or skip the key entirely and add Leonardo.Ai models to a web app for free with Puter.js.
Related
- Free, Unlimited Image Generation API
- Free, Unlimited Flux API
- Free, Unlimited Stable Diffusion API
- Free, Unlimited GPT Image API
- Free, Unlimited Claude API
- How to Get an OpenAI API Key
- How to Get an Anthropic (Claude) API Key
- How to Get a Gemini API Key
- How to Get a Grok (xAI) API Key
- How to Get a DeepSeek API Key
- How to Get an ElevenLabs API Key
- How to Get a Mistral API Key
- How to Get a MiniMax API Key
- How to Get a Moonshot AI (Kimi) API Key
- How to Get a Qwen API Key
- How to Get a Z.AI (GLM) API Key
- How to Get an OpenRouter API Key
- How to Get a Stability AI (Stable Diffusion) API Key
- How to Get a Kling API Key
- How to Get a Together AI API Key
- How to Get a Cohere API Key
- How to Get a FLUX (Black Forest Labs) API Key
- How to Use OpenAI SDK with Puter
- How to Use LangChain with Puter
- How to Use Vercel AI SDK with Puter