canonical: https://jentic.com/apis/leonardo.ai/leonardo

# Leonardo.Ai API

The Leonardo.Ai API generates images and video from text prompts and trains custom image models, exposing generations, datasets, models, and variations over a REST interface. It lets you start a generation, poll for its results, build datasets, train a custom model, and run upscales and other variations on an image. Requests carry a bearer token and return structured JSON your application can act on.

## For AI agents

Generate images and video from prompts, train custom models on your datasets, and run upscales and variations with the Leonardo.Ai API. Covers 55 endpoints across generations, datasets, models, and variations.

## Scope

Does not host or serve the generated assets long term. Use for creating generations, training models, and running image variations only.

## Capabilities

- Create image generations from a text prompt and poll for the results
- Retrieve a generation and its resulting images by ID
- Create datasets and upload images for model training
- Train a custom model on your own dataset
- Run upscale, unzoom, and background-removal variations on an image
- Improve or generate prompts before creating images

## Use cases

### AI Creative Agent via Jentic

An AI creative agent can generate and refine images without a developer wiring the Leonardo.Ai API by hand. Through Jentic the agent searches for the generation operation by intent, receives the endpoint and its input schema, and calls it with the bearer token injected at execution time. The agent then polls the generation by ID and returns the finished images.

Example prompt: Search Jentic for 'create an image generation', call POST /generations with the prompt, then poll GET `/generations/{id}` until the images are ready

### Custom Model Training

Teams with their own image style can train a custom model rather than relying on base models. The Leonardo.Ai API builds a dataset, uploads training images, and trains a model against it, so a pipeline can produce a bespoke model programmatically. The trained model is then available for later generations.

Example prompt: Call POST /datasets to create a dataset, upload images to it, then POST /models to train a custom model on the dataset

### Image Post-Processing

Applications that generate images often need to upscale or clean them up before delivery. The Leonardo.Ai API runs upscale, unzoom, and background-removal variations on an existing image, so a post-processing step can polish each result. This produces delivery-ready assets without leaving the platform.

Example prompt: Call POST `/variations/upscale` on a generated image, then retrieve the variation result by ID

## Key endpoints

| Method | Path | Description |
| --- | --- | --- |
| POST | `/generations` | Create a generation of images |
| GET | `/generations/{id}` | Get a single generation |
| POST | `/datasets` | Create a dataset |
| POST | `/models` | Train a custom model |
| POST | `/variations/upscale` | Create an upscale variation |
| POST | `/prompt/improve` | Improve a prompt |
| POST | `/generations-text-to-video` | Create a video generation from a text prompt |
| GET | `/me` | Get user information |

## Key resources

- **Generations** — Create image and video generations and retrieve their results
- **Datasets** — Create datasets and upload images for training
- **Models** — Train and read custom image models
- **Variations** — Run upscale, unzoom, and background-removal on images
- **Prompt** — Improve or generate prompts before generating images

## Why Jentic

- **Setup:** Wiring the Leonardo.Ai API by hand means setting the bearer token on every request, starting a generation, and polling its ID until the images are ready yourself. Through Jentic you install once, import Leonardo.Ai from the API Directory, store the token once, and your agent calls it.
- **Permission scoping:** Leonardo.Ai puts the record id in the URL path (`/generations/{id}`, `/datasets/{id}`), so a rule can pin your agent to creating and reading generations. You choose the operations it may call, so training a model or deleting a dataset is not included unless you add it.
- **Credential handling:** Your Leonardo.Ai token is stored once, encrypted, by your own Jentic One instance and injected at execution time. It never enters the agent's prompt, logs, or context.
- **Discovery method:** Agents search Jentic by intent such as 'create an image generation' or 'train a custom model', and Jentic returns the matching Leonardo.Ai operation with its input schema so the agent calls the right endpoint without browsing the reference docs.

## Related APIs

- **Stability AI** — Text-to-image generation with Stable Diffusion models
- **OpenAI** — Image generation alongside language and audio models
- **Replicate** — Run and host a broad catalog of open image and video models

## FAQ

### What authentication does the Leonardo.Ai API use?

The Leonardo.Ai API authenticates with a bearer token in the Authorization header, as declared in its OpenAPI spec. Through Jentic the token is stored encrypted by your own Jentic One instance and injected at execution time, so it never enters the agent's prompt, logs, or context.

### How do I get the images from a generation with the Leonardo.Ai API?

Call POST /generations to start a generation, which returns a generation ID, then poll GET `/generations/{id}` until the images are ready. The generation response carries the URLs of the finished images so your agent can download them.

### What are the rate limits for the Leonardo.Ai API?

The OpenAPI spec does not specify rate limits. Check the Leonardo.Ai API documentation at https://docs.leonardo.ai for current limits before running high-volume generation jobs.

### How do I generate images through Jentic?

Search Jentic for 'create an image generation', which resolves to the POST /generations operation, and Jentic returns its input schema so your agent can submit a prompt and poll for results. Credentials are injected at call time from your own instance. To run it on your own infrastructure, install Jentic One from its GitHub repo.

### Can I restrict what my agent is allowed to do with the Leonardo.Ai API?

Yes. Write a rule that allows only the operations your agent needs, such as POST /generations and GET `/generations/{id}`, so it can create and read generations but cannot train models or delete datasets, and every call it makes is logged by your own instance. You add training or delete operations to the allowed set only when you decide to.

### Is there a Leonardo.Ai MCP server?

You don't need an MCP server to give your agent Leonardo.Ai. Jentic connects it directly from the API Directory: import Leonardo.Ai, store your token once, and your agent calls the generation, dataset, and model operations on demand without loading another server's tool definitions into its context.
