# Leonardo.AI

> Generate images, improve prompts, manage datasets and inspect models, elements and generation jobs.

App · 20 actions. Web page: https://docs.lodol.com/docs/integrations/leonardo-ai

## Actions

### Create dataset

Create dataset.

**Inputs**

- Name (`name`, text, required): The name of the dataset.
- Description (`description`, text): A description for the dataset.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "insert_datasets_one": {
      "id": "example"
    }
  }
}
```

### Create generation

Create generation.

**Inputs**

- Alchemy (`alchemy`, true/false): Enable to use Alchemy. Note: The appropriate Alchemy version is selected for the specified model. For example, XL models will use Alchemy V2. Default: `true`.
- Contrast ratio (`contrast_ratio`, number): Contrast Ratio to use with Alchemy. Must be a float between 0 and 1 inclusive.
- Contrast (`contrast`, number): Adjusts the contrast level of the generated image. Used in Phoenix and Flux models. Accepts values [1.0, 1.3, 1.8, 2.5, 3, 3.5, 4, 4.5]. For Phoenix, if alchemy is true, contrast needs to be 2.5 or higher. From 1 to 4.5.
- Controlnets (`controlnets`, list): Controlnets.
- Elements (`elements`, list): Elements.
- User elements (`user_elements`, list): User elements.
- Expanded domain (`expanded_domain`, true/false): Enable to use the Expanded Domain feature of Alchemy.
- Fantasy avatar (`fantasy_avatar`, true/false): Enable to use the Fantasy Avatar feature.
- Guidance scale (`guidance_scale`, number): How strongly the generation should reflect the prompt. 7 is recommended. Must be between 1 and 20.
- Height (`height`, number): The input height of the images. Must be between 32 and 1536 and be a multiple of 8. Note: Input resolution is not always the same as output resolution due to upscaling from other features. Default: `768`.
- High contrast (`high_contrast`, true/false): Enable to use the High Contrast feature of Prompt Magic. Note: Controls RAW mode. Set to false to enable RAW mode.
- High resolution (`high_resolution`, true/false): Enable to use the High Resolution feature of Prompt Magic.
- Image prompts (`image_prompts`, list): Image prompts.
- Image prompt weight (`image_prompt_weight`, number): Image prompt weight.
- Init generation image ID (`init_generation_image_id`, text): The ID of an existing image to use in image2image.
- Init image ID (`init_image_id`, text): The ID of an Init Image to use in image2image.
- Init strength (`init_strength`, number): How strongly the generated images should reflect the original image in image2image. Must be a float between 0.1 and 0.9.
- Model (`model_id`, text): The model ID used for image generation. If not provided, uses sd_version to determine the version of Stable Diffusion to use. In-app, model IDs are under the Finetune Models menu. Click on the platform model or your custom model, then click View More. For platform models, you can also use the List Platform Models API.
- Negative prompt (`negative_prompt`, text): The negative prompt used for the image generation
- Num images (`num_images`, number): The number of images to generate. Must be between 1 and 8. If either width or height is over 768, must be between 1 and 4. Default: `1`.
- Num inference steps (`num_inference_steps`, number): The Step Count to use for the generation. Must be between 10 and 60. Default is 15.
- Photo real (`photo_real`, true/false): Enable the photoReal feature. Requires enabling alchemy and unspecifying modelId (for photoRealVersion V1).
- Photo real version (`photo_real_version`, text): The version of photoReal to use. Must be v1 or v2.
- Photo real strength (`photo_real_strength`, number): Depth of field of photoReal. Must be 0.55 for low, 0.5 for medium, or 0.45 for high. Defaults to 0.55 if not specified.
- Preset style (`preset_style`, text): The style to generate images with. When photoReal is enabled, refer to the Guide section for a full list. When alchemy is disabled, use LEONARDO or NONE. When alchemy is enabled, use ANIME, CREATIVE, DYNAMIC, ENVIRONMENT, GENERAL, ILLUSTRATION, PHOTOGRAPHY, RAYTRACED, RENDER_3D, SKETCH_BW, SKETCH_COLOR, or NONE. One of: `ANIME`, `BOKEH`, `CINEMATIC`, `CINEMATIC_CLOSEUP` (Cinematic closeup), `CREATIVE`, `DYNAMIC`, `ENVIRONMENT`, `FASHION`, `FILM`, `FOOD`, and 21 more. Default: `DYNAMIC`.
- Prompt (`prompt`, text, required): The prompt used to generate images
- Prompt magic (`prompt_magic`, true/false): Enable to use Prompt Magic.
- Prompt magic strength (`prompt_magic_strength`, number): Strength of prompt magic. Must be a float between 0.1 and 1.0
- Prompt magic version (`prompt_magic_version`, text): Prompt magic version v2 or v3, for use when promptMagic: true
- Public (`public`, true/false): Whether the generated images should show in the community feed.
- Scheduler (`scheduler`, text): The scheduler to generate images with. Defaults to EULER_DISCRETE if not specified. One of: `KLMS`, `EULER_ANCESTRAL_DISCRETE` (Euler ancestral discrete), `EULER_DISCRETE` (Euler discrete), `DDIM`, `DPM_SOLVER` (Dpm solver), `PNDM`, `LEONARDO`.
- Sd version (`sd_version`, text): The base version of stable diffusion to use if not using a custom model. v1_5 is 1.5, v2 is 2.1, if not specified it will default to v1_5. Also includes SDXL and SDXL Lightning models. One of: `v1_5` (V1 5), `v2`, `v3`, `SDXL_0_8` (Sdxl 0 8), `SDXL_0_9` (Sdxl 0 9), `SDXL_1_0` (Sdxl 1 0), `SDXL_LIGHTNING` (Sdxl lightning), `PHOENIX`, `FLUX`, `FLUX_DEV` (Flux dev), `KINO_2_0` (Kino 2 0).
- Seed (`seed`, number): Apply a fixed seed to maintain consistency across generation sets. The maximum seed value is 2147483637 for Flux and 9999999998 for other models
- Tiling (`tiling`, true/false): Whether the generated images should tile on all axis.
- Transparency (`transparency`, text): Which type of transparency this image should use. One of: `disabled`, `foreground_only` (Foreground only).
- Ultra (`ultra`, true/false): Enable to use Ultra mode. Note: can not be used with Alchemy.
- Unzoom (`unzoom`, true/false): Whether the generated images should be unzoomed (requires unzoomAmount and init_image_id to be set).
- Unzoom amount (`unzoom_amount`, number): How much the image should be unzoomed (requires an init_image_id and unzoom to be set to true).
- Upscale ratio (`upscale_ratio`, number): How much the image should be upscaled. (Enterprise Only)
- Width (`width`, number): The input width of the images. Must be between 32 and 1536 and be a multiple of 8. Note: Input resolution is not always the same as output resolution due to upscaling from other features. Default: `1024`.
- Control net (`control_net`, true/false): This parameter will be deprecated in September 2024. Please use the controlnets array instead.
- Control net type (`control_net_type`, text): This parameter will be deprecated in September 2024. Please use the controlnets array instead. One of: `POSE`, `CANNY`, `DEPTH`.
- Weighting (`weighting`, number): This parameter will be deprecated in September 2024. Please use the controlnets array instead.
- Canvas request (`canvas_request`, true/false): Whether the generation is for the Canvas Editor feature.
- Canvas request type (`canvas_request_type`, text): The type of request for the Canvas Editor. One of: `INPAINT`, `OUTPAINT`, `SKETCH2IMG`, `IMG2IMG`.
- Canvas init ID (`canvas_init_id`, text): The ID of an initial image to use in Canvas Editor request.
- Canvas mask ID (`canvas_mask_id`, text): The ID of a mask image to use in Canvas Editor request.
- Enhance prompt (`enhance_prompt`, true/false): When enabled, your prompt is expanded to include more detail.
- Enhance prompt instruction (`enhance_prompt_instruction`, text): When enhancePrompt is enabled, the prompt is enhanced based on the given instructions.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "sdGenerationJob": {
      "apiCreditCost": 1,
      "cost": {
        "amount": "example",
        "unit": "CREDITS"
      },
      "generationId": "example"
    }
  }
}
```

### Delete dataset

Delete dataset.

**Inputs**

- Id (`id`, text, required): Id.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "delete_datasets_by_pk": {
      "id": "example"
    }
  }
}
```

### Delete generation

Delete generation.

**Inputs**

- Id (`id`, text, required): Id.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "delete_generations_by_pk": {
      "id": "example"
    }
  }
}
```

### Delete init image

Delete init image.

**Inputs**

- Id (`id`, text, required): Id.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "delete_init_images_by_pk": {
      "id": "example"
    }
  }
}
```

### Generate random prompt

Generate random prompt.

**Inputs**: None.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "promptGeneration": {
      "apiCreditCost": 1,
      "cost": {
        "amount": "example",
        "unit": "CREDITS"
      },
      "prompt": "example"
    }
  }
}
```

### Get dataset

Get dataset.

**Inputs**

- Id (`id`, text, required): Id.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "datasets_by_pk": {
      "createdAt": "example",
      "dataset_images": [],
      "description": "example",
      "id": "example",
      "name": "example",
      "updatedAt": "example"
    }
  }
}
```

### Get element

Get element.

**Inputs**

- Id (`id`, number, required): Id.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "user_loras_by_pk": {
      "baseModel": "example",
      "createdAt": "example",
      "description": "example",
      "focus": "example",
      "id": 1,
      "instancePrompt": "example",
      "learningRate": 1.0,
      "name": "example",
      "resolution": 1,
      "status": "PENDING",
      "trainTextEncoder": false,
      "trainingEpoch": 1,
      "updatedAt": "example"
    }
  }
}
```

### Get generation

Get generation.

**Inputs**

- Id (`id`, text, required): Id.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "generations_by_pk": {
      "createdAt": "example",
      "generated_images": [],
      "generation_elements": [],
      "guidanceScale": 1.0,
      "id": "example",
      "imageHeight": 1,
      "imageWidth": 1,
      "inferenceSteps": 1,
      "initStrength": 1.0,
      "modelId": "example",
      "negativePrompt": "example",
      "photoReal": false,
      "photoRealStrength": 1.0,
      "presetStyle": "ANIME",
      "prompt": "example",
      "promptMagic": false,
      "promptMagicStrength": 1.0,
      "promptMagicVersion": "example",
      "public": false,
      "scheduler": "KLMS",
      "sdVersion": "v1_5",
      "seed": 1,
      "status": "PENDING",
      "ultra": false
    }
  }
}
```

### Get init image

Get init image.

**Inputs**

- Id (`id`, text, required): Id.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "init_images_by_pk": {
      "createdAt": "example",
      "id": "example",
      "url": "example"
    }
  }
}
```

### Get model

Get model.

**Inputs**

- Id (`id`, text, required): Id.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "custom_models_by_pk": {
      "createdAt": "example",
      "description": "example",
      "id": "example",
      "instancePrompt": "example",
      "modelHeight": 1,
      "modelWidth": 1,
      "name": "example",
      "public": false,
      "sdVersion": "v1_5",
      "status": "PENDING",
      "type": "GENERAL",
      "updatedAt": "example"
    }
  }
}
```

### Get user

Get user.

**Inputs**: None.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "user_details": []
  }
}
```

### Get variations

Get variations.

**Inputs**

- Id (`id`, text, required): Id.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "generated_image_variation_generic": []
  }
}
```

### Improve prompt

Improve prompt.

**Inputs**

- Prompt (`prompt`, text, required): The prompt to improve.
- Prompt instructions (`prompt_instructions`, text): The prompt is improved based on the given instructions.
- Is video (`is_video`, true/false): Specifies whether the prompt is for a video generation. Defaults to false (image prompt).

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "promptGeneration": {
      "apiCreditCost": 1,
      "cost": {
        "amount": "example",
        "unit": "CREDITS"
      },
      "prompt": "example"
    }
  }
}
```

### List custom elements

List custom elements.

**Inputs**

- Leonardo user ID (`leonardo_user_id`, text, required): User ID.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "user_loras": []
  }
}
```

### List custom models

List custom models.

**Inputs**

- Leonardo user ID (`leonardo_user_id`, text, required): User ID.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "custom_models": []
  }
}
```

### List elements

List elements.

**Inputs**: None.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "loras": []
  }
}
```

### List generations

List generations.

**Inputs**

- Offset (`offset`, number): Offset. Default: `0`.
- Limit (`limit`, number): Limit. Default: `10`.
- Leonardo user ID (`leonardo_user_id`, text, required): User ID.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "generations": []
  }
}
```

### List platform models

List platform models.

**Inputs**: None.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "custom_models": []
  }
}
```

### Upscale image

Upscale image.

**Inputs**

- Id (`id`, text, required): Id.

**Outputs**

- `data` (object): Response.

**Example output**

```json
{
  "data": {
    "sdUpscaleJob": {
      "apiCreditCost": 1,
      "cost": {
        "amount": "example",
        "unit": "CREDITS"
      },
      "id": "example"
    }
  }
}
```
