Skip to content

Commit 61d5961

Browse files
Leonardo AI components
1 parent 194d1ef commit 61d5961

File tree

9 files changed

+605
-5
lines changed

9 files changed

+605
-5
lines changed

components/leonardo_ai/README.md

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
# Leonardo AI
2+
3+
[Leonardo AI](https://leonardo.ai) is an AI-powered image generation platform that allows you to create stunning images, videos, and 3D models using advanced machine learning models.
4+
5+
## Authentication
6+
7+
To use this component, you'll need to:
8+
9+
1. Sign up for a Leonardo AI account at [leonardo.ai](https://leonardo.ai)
10+
2. Navigate to the API section in your account settings
11+
3. Create an API key
12+
4. Use this API key when connecting the Leonardo AI app in Pipedream
13+
14+
## Actions
15+
16+
### Generate Image
17+
Creates new images from text prompts using Leonardo AI's image generation models.
18+
19+
**Key Features:**
20+
- Customizable image dimensions (256x256 to 1024x1024)
21+
- Multiple model support
22+
- Adjustable guidance scale and inference steps
23+
- Batch generation (1-4 images)
24+
- Seed support for reproducible results
25+
26+
### Generate Motion
27+
Creates motion videos from static images using Leonardo AI's SVD Motion Generation.
28+
29+
**Key Features:**
30+
- Converts static images to motion videos
31+
- Adjustable motion strength
32+
- Seed support for reproducible results
33+
34+
### Unzoom Image
35+
Creates unzoom variations of existing images, expanding the scene beyond the original frame.
36+
37+
**Key Features:**
38+
- Zoom out effect on existing images
39+
- Adjustable zoom level
40+
- Works with generated or uploaded images
41+
42+
### Upload Image
43+
Uploads images to Leonardo AI for use in generations and variations.
44+
45+
**Key Features:**
46+
- Support for image URLs
47+
- Optional image naming
48+
- Integration with other Leonardo AI actions
49+
50+
### Upscale Image
51+
Increases the resolution of images using Leonardo AI's Universal Upscaler.
52+
53+
**Key Features:**
54+
- Multiple upscaling modes (Universal Upscaler, Real-ESRGAN)
55+
- 2x and 4x scale factors
56+
- High-quality image enhancement
57+
58+
## Usage Examples
59+
60+
### Basic Image Generation
61+
```javascript
62+
// Generate a simple image
63+
{
64+
"prompt": "A beautiful sunset over mountains",
65+
"width": 512,
66+
"height": 512,
67+
"numImages": 1
68+
}
69+
```
70+
71+
### Advanced Image Generation
72+
```javascript
73+
// Generate with specific model and settings
74+
{
75+
"prompt": "A cyberpunk cityscape at night",
76+
"modelId": "6bef9f1b-29cb-40c7-b9df-32b51c1f67d3",
77+
"width": 1024,
78+
"height": 1024,
79+
"numImages": 2,
80+
"guidanceScale": "10",
81+
"numInferenceSteps": 30,
82+
"seed": 12345
83+
}
84+
```
85+
86+
### Motion Generation
87+
```javascript
88+
// Create motion from an image
89+
{
90+
"imageId": "generated-image-id-here",
91+
"motionStrength": "0.7",
92+
"seed": 54321
93+
}
94+
```
95+
96+
## API Reference
97+
98+
For detailed information about Leonardo AI's API, visit the [official documentation](https://docs.leonardo.ai/reference).
99+
100+
## Rate Limits
101+
102+
Leonardo AI has the following rate limits:
103+
- Total requests: 1,000 per minute
104+
- Image generation requests: 100 per minute
105+
- Concurrent image generation jobs: 10
106+
- Concurrent model training jobs: 5
107+
108+
## Support
109+
110+
For support with this component or Leonardo AI's API, please refer to:
111+
- [Leonardo AI Documentation](https://docs.leonardo.ai)
112+
- [Leonardo AI Community](https://community.leonardo.ai)
113+
- [Pipedream Support](https://pipedream.com/support)
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
import app from "../../leonardo_ai.app.mjs";
2+
3+
export default {
4+
key: "leonardo_ai-generate-image",
5+
name: "Generate Image",
6+
description: "Generates new images using Leonardo AI's image generation API.",
7+
version: "0.0.5",
8+
type: "action",
9+
props: {
10+
app,
11+
prompt: {
12+
type: "string",
13+
label: "Prompt",
14+
description: "The text prompt describing the image you want to generate.",
15+
},
16+
modelId: {
17+
type: "string",
18+
label: "Model",
19+
description: "The model to use for generation. Leave empty to use the default model.",
20+
async options() {
21+
const models = await this.app.getPlatformModels({});
22+
return models.map((model) => ({
23+
label: model.name || model.id,
24+
value: model.id,
25+
}));
26+
},
27+
optional: true,
28+
},
29+
width: {
30+
type: "integer",
31+
label: "Width",
32+
description: "Width of the generated image in pixels.",
33+
default: 512,
34+
min: 256,
35+
max: 1024,
36+
},
37+
height: {
38+
type: "integer",
39+
label: "Height",
40+
description: "Height of the generated image in pixels.",
41+
default: 512,
42+
min: 256,
43+
max: 1024,
44+
},
45+
numImages: {
46+
type: "integer",
47+
label: "Number of Images",
48+
description: "Number of images to generate (1-4).",
49+
default: 1,
50+
min: 1,
51+
max: 4,
52+
},
53+
guidanceScale: {
54+
type: "string",
55+
label: "Guidance Scale",
56+
description: "How closely the model should follow the prompt. Must be between 1 and 20. Higher values = more adherence to prompt.",
57+
optional: true,
58+
},
59+
numInferenceSteps: {
60+
type: "integer",
61+
label: "Inference Steps",
62+
description: "Number of denoising steps. More steps = higher quality but slower generation.",
63+
default: 20,
64+
min: 10,
65+
max: 50,
66+
optional: true,
67+
},
68+
seed: {
69+
type: "integer",
70+
label: "Seed",
71+
description: "Random seed for reproducible generation. Leave empty for random generation.",
72+
optional: true,
73+
},
74+
},
75+
async run({ $ }) {
76+
const {
77+
prompt,
78+
modelId,
79+
width,
80+
height,
81+
numImages,
82+
guidanceScale,
83+
numInferenceSteps,
84+
seed,
85+
} = this;
86+
87+
const data = {
88+
prompt,
89+
width,
90+
height,
91+
num_images: numImages,
92+
};
93+
94+
if (modelId) {
95+
data.modelId = modelId;
96+
}
97+
if (guidanceScale) {
98+
data.guidance_scale = parseFloat(guidanceScale);
99+
}
100+
if (numInferenceSteps) {
101+
data.num_inference_steps = numInferenceSteps;
102+
}
103+
if (seed) {
104+
data.seed = seed;
105+
}
106+
107+
const response = await this.app.post({
108+
$,
109+
path: "/generations",
110+
data,
111+
});
112+
113+
$.export("$summary", `Successfully generated ${numImages} image(s) with prompt: "${prompt}"`);
114+
return response;
115+
},
116+
};
Lines changed: 76 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,76 @@
1+
import app from "../../leonardo_ai.app.mjs";
2+
3+
export default {
4+
key: "leonardo_ai-generate-motion",
5+
name: "Generate Motion",
6+
description: "Generates a motion (video) from the provided image using Leonardo AI's SVD Motion Generation API.",
7+
version: "0.0.4",
8+
type: "action",
9+
props: {
10+
app,
11+
imageId: {
12+
type: "string",
13+
label: "Image ID",
14+
description: "The ID of the image to generate motion from. This should be a previously generated or uploaded image ID.",
15+
},
16+
motionStrength: {
17+
type: "integer",
18+
label: "Motion Strength",
19+
description: "The motion strength for the video generation.",
20+
optional: true,
21+
},
22+
isPublic: {
23+
type: "boolean",
24+
label: "Is Public",
25+
description: "Whether the generation is public or not.",
26+
optional: true,
27+
},
28+
isInitImage: {
29+
type: "boolean",
30+
label: "Is Init Image",
31+
description: "If it is an init image uploaded by the user.",
32+
optional: true,
33+
},
34+
isVariation: {
35+
type: "boolean",
36+
label: "Is Variation",
37+
description: "If it is a variation image.",
38+
optional: true,
39+
},
40+
},
41+
async run({ $ }) {
42+
const {
43+
imageId,
44+
motionStrength,
45+
isPublic,
46+
isInitImage,
47+
isVariation,
48+
} = this;
49+
50+
const data = {
51+
imageId,
52+
};
53+
54+
if (motionStrength !== undefined) {
55+
data.motionStrength = motionStrength;
56+
}
57+
if (isPublic !== undefined) {
58+
data.isPublic = isPublic;
59+
}
60+
if (isInitImage !== undefined) {
61+
data.isInitImage = isInitImage;
62+
}
63+
if (isVariation !== undefined) {
64+
data.isVariation = isVariation;
65+
}
66+
67+
const response = await this.app.post({
68+
$,
69+
path: "/generations-motion-svd",
70+
data,
71+
});
72+
73+
$.export("$summary", `Successfully generated motion from image ID: ${imageId}`);
74+
return response;
75+
},
76+
};
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
---
2+
alwaysApply: true
3+
---
4+
leonardo-ai
5+
URLs
6+
https://docs.leonardo.ai/reference
7+
Actions
8+
generate-motion
9+
Prompt
10+
Generates a motion (video) from the provided image (any type).
11+
12+
generate-image
13+
Prompt
14+
Generates new images.
15+
16+
unzoom-image
17+
Prompt
18+
Creates an unzoom variation for a generated or variation image.
19+
20+
upload-image
21+
Prompt
22+
Uploads a new image.
23+
24+
upscale-image
25+
Prompt
26+
Creates a high-resolution upscale (Universal Upscaler) of the provided image (any type).
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
import app from "../../leonardo_ai.app.mjs";
2+
3+
export default {
4+
key: "leonardo_ai-unzoom-image",
5+
name: "Unzoom Image",
6+
description: "Creates an unzoom variation for a generated or variation image using Leonardo AI's unzoom API.",
7+
version: "0.0.1",
8+
type: "action",
9+
props: {
10+
app,
11+
imageId: {
12+
type: "string",
13+
label: "Image ID",
14+
description: "The ID of the image to create an unzoom variation for. This should be a previously generated or variation image ID.",
15+
},
16+
zoom: {
17+
type: "string",
18+
label: "Zoom Level",
19+
description: "Zoom level for the unzoom effect. Must be between 0.0 and 1.0. Higher values create more zoom out effect.",
20+
default: "0.5",
21+
optional: true,
22+
},
23+
seed: {
24+
type: "integer",
25+
label: "Seed",
26+
description: "Random seed for reproducible generation. Leave empty for random generation.",
27+
optional: true,
28+
},
29+
},
30+
async run({ $ }) {
31+
const {
32+
imageId,
33+
zoom,
34+
seed,
35+
} = this;
36+
37+
const data = {
38+
imageId,
39+
zoom: zoom ? parseFloat(zoom) : 0.5,
40+
};
41+
42+
if (seed) {
43+
data.seed = seed;
44+
}
45+
46+
const response = await this.app.post({
47+
$,
48+
path: "/variations/unzoom",
49+
data,
50+
});
51+
52+
$.export("$summary", `Successfully created unzoom variation for image ID: ${imageId}`);
53+
return response;
54+
},
55+
};

0 commit comments

Comments
 (0)