- 
                Notifications
    You must be signed in to change notification settings 
- Fork 5.5k
Leonardo components #18362
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Leonardo components #18362
Changes from 51 commits
61d5961
              1f0e5b4
              43c2645
              185b2cd
              b52e6af
              768d13e
              cab79a5
              ab578e6
              47cc79a
              39af3b6
              53176bc
              48338b7
              cdbc17b
              4ea8c2e
              0c0e183
              8268c0e
              d5c554d
              07aa960
              cef1e1b
              3cb8df5
              6f23e27
              e35feaf
              874a7cf
              f381c67
              d11624e
              dc3964a
              bbde963
              fc90f7b
              961dd55
              e838ebe
              85bd98a
              2dfb941
              ffa140c
              1884cf0
              4e0aa1d
              5a236a9
              52c9a94
              5e65398
              7073397
              61539b7
              2863b95
              d15d706
              1721bbf
              0185460
              72c48a3
              8b4f66c
              3260986
              7a6774b
              d2d0b88
              c04c193
              b5f7dce
              1d35b09
              18e7669
              6765ddc
              File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,95 @@ | ||
| # Leonardo AI | ||
|  | ||
| [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. | ||
|  | ||
| ## Actions | ||
|  | ||
| ### Generate Image | ||
| Creates new images from text prompts using Leonardo AI's image generation models. | ||
|  | ||
| **Key Features:** | ||
| - Customizable image dimensions (256x256 to 1024x1024) | ||
| - Multiple model support | ||
| - Adjustable guidance scale and inference steps | ||
| - Batch generation (1-4 images) | ||
| - Seed support for reproducible results | ||
|  | ||
| ### Generate Motion | ||
| Creates motion videos from static images using Leonardo AI's SVD Motion Generation. | ||
|  | ||
| **Key Features:** | ||
| - Converts static images to motion videos | ||
| - Adjustable motion strength | ||
| - Seed support for reproducible results | ||
|  | ||
| ### Unzoom Image | ||
| Creates unzoom variations of existing images, expanding the scene beyond the original frame. | ||
|  | ||
| **Key Features:** | ||
| - Zoom out effect on existing images | ||
| - Adjustable zoom level | ||
| - Works with generated or uploaded images | ||
|  | ||
| ### Upload Image | ||
| Uploads images to Leonardo AI for use in generations and variations. | ||
|  | ||
| ### Upscale Image | ||
| Increases the resolution of images using Leonardo AI's Universal Upscaler. | ||
|  | ||
| **Key Features:** | ||
| - Multiple upscaling modes (Universal Upscaler, Real-ESRGAN) | ||
| - 2x and 4x scale factors | ||
| - High-quality image enhancement | ||
|  | ||
| ## Usage Examples | ||
|  | ||
| ### Basic Image Generation | ||
| ```javascript | ||
| // Generate a simple image | ||
| { | ||
| "prompt": "A beautiful sunset over mountains", | ||
| "width": 512, | ||
| "height": 512, | ||
| "numImages": 1 | ||
| } | ||
| ``` | ||
|  | ||
| ### Advanced Image Generation | ||
| ```javascript | ||
| // Generate with specific model and settings | ||
| { | ||
| "prompt": "A cyberpunk cityscape at night", | ||
| "modelId": "6bef9f1b-29cb-40c7-b9df-32b51c1f67d3", | ||
| "width": 1024, | ||
| "height": 1024, | ||
| "numImages": 2, | ||
| "guidanceScale": "10", | ||
| "numInferenceSteps": 30, | ||
| "seed": 12345 | ||
| } | ||
| ``` | ||
|  | ||
| ### Motion Generation | ||
| ```javascript | ||
| // Create motion from an image | ||
| { | ||
| "imageId": "generated-image-id-here", | ||
| "motionStrength": "0.7", | ||
| "seed": 54321 | ||
| } | ||
| ``` | ||
|  | ||
| ## API Reference | ||
|  | ||
| For detailed information about Leonardo AI's API, visit the [official documentation](https://docs.leonardo.ai/reference). | ||
|  | ||
| ## Rate Limits | ||
|  | ||
| See the official Leonardo AI documentation for current limits. | ||
|  | ||
| ## Support | ||
|  | ||
| For support with this component or Leonardo AI's API, please refer to: | ||
| - [Leonardo AI Documentation](https://docs.leonardo.ai) | ||
| - [Leonardo AI Community](https://community.leonardo.ai) | ||
| - [Pipedream Support](https://pipedream.com/support) | 
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,111 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import app from "../../leonardo_ai.app.mjs"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| export default { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| key: "leonardo_ai-generate-image", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| name: "Generate Image", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Generates new images using Leonardo AI's image generation API. [See the documentation](https://docs.leonardo.ai/reference/creategeneration)", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| version: "0.0.1", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "action", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| props: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| app, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prompt: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Prompt", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "The text prompt describing the image you want to generate.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| modelId: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "string", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Model", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "The model to use for generation. Leave empty to use the default model.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async options() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const models = await this.app.getPlatformModels(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return models.map((model) => ({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: model.name || model.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| value: model.id, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| })); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| width: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "integer", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Width", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Width of the generated image in pixels.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: 1024, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| min: 32, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| max: 1536, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| height: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "integer", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Height", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Height of the generated image in pixels.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: 768, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| min: 32, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| max: 1536, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| numImages: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "integer", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Number of Images", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Number of images to generate (1-8). If either width or height is over 768, must be between 1 and 4.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| min: 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| max: 8, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| guidanceScale: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "integer", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Guidance Scale", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "How closely the model should follow the prompt. Must be between 1 and 20. Higher values = more adherence to prompt.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: 7, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| min: 1, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| max: 20, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| numInferenceSteps: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "integer", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Inference Steps", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Number of denoising steps. More steps = higher quality but slower generation.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| default: 15, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| min: 10, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| max: 60, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| seed: { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| type: "integer", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| label: "Seed", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| description: "Random seed for reproducible generation. Leave empty for random generation.", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| optional: true, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| async run({ $ }) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prompt, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| modelId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| width, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| height, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| numImages, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| guidanceScale, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| numInferenceSteps, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| seed, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } = this; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const data = { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| prompt, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| width, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| height, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| num_images: numImages, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| modelId, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| guidance_scale: guidanceScale, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| num_inference_steps: numInferenceSteps, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| seed: seed | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 
      Comment on lines
    
      78
     to 
      99
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Enforce image count vs. size constraint before calling the API. Leonardo limits     async run({ $ }) {
     const {
       prompt,
       modelId,
       width,
       height,
       numImages,
       guidanceScale,
       numInferenceSteps,
       seed,
     } = this;
+    if ((width > 768 || height > 768) && numImages > 4) {
+      throw new Error("When width or height exceeds 768, Number of Images must be 1–4.");
+    }📝 Committable suggestion
 
        Suggested change
       
 🤖 Prompt for AI Agents | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const response = await this.app._makeRequest({ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| method: "POST", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| path: "/generations", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| data, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|  | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| $.export("$summary", `Successfully generated ${numImages} image(s)`); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| return response; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,68 @@ | ||
| import app from "../../leonardo_ai.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "leonardo_ai-generate-motion", | ||
| name: "Generate Motion", | ||
| description: "Generates a motion (video) from the provided image using Leonardo AI's SVD Motion Generation API. [See the documentation](https://docs.leonardo.ai/reference/createsvdmotiongeneration)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| imageId: { | ||
| type: "string", | ||
| label: "Image ID", | ||
| description: "The ID of the image to generate motion from. This should be a previously generated or uploaded image ID.", | ||
| }, | ||
| 
      Comment on lines
    
      11
     to 
      64
    
   There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any chance we can use async options here to list available images? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes. This was is tricky because it needs merging two different types of image entities. I'll give a shot. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I checked—there’s no way to retrieve previously uploaded images. But we could scope async options to only list generated images using this endpoint. Thoughts? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think it's better to list some options than none at all, so go for it. The description should make this clear though, something like  There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yep, an async options method was implemented for imageId showing options for image generations and description was modified accordingly. | ||
| motionStrength: { | ||
| type: "integer", | ||
| label: "Motion Strength", | ||
| description: "The motion strength for the video generation.", | ||
| optional: true, | ||
| }, | ||
| isPublic: { | ||
| type: "boolean", | ||
| label: "Is Public", | ||
| description: "Whether the generation is public or not.", | ||
| optional: true, | ||
| }, | ||
| isInitImage: { | ||
| type: "boolean", | ||
| label: "Is Init Image", | ||
| description: "Whether the image being used is an init image uploaded by the user.", | ||
| optional: true, | ||
| }, | ||
| isVariation: { | ||
| type: "boolean", | ||
| label: "Is Variation", | ||
| description: "Whether the image being used is a variation image.", | ||
| optional: true, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| imageId, | ||
| motionStrength, | ||
| isPublic, | ||
| isInitImage, | ||
| isVariation, | ||
| } = this; | ||
|  | ||
| const data = { | ||
| imageId, | ||
| motionStrength, | ||
| isPublic, | ||
| isInitImage, | ||
| isVariation, | ||
| }; | ||
|  | ||
| const response = await this.app._makeRequest({ | ||
| $, | ||
| method: "POST", | ||
| path: "/generations-motion-svd", | ||
| data, | ||
| }); | ||
|  | ||
| $.export("$summary", `Successfully generated motion from image ID: ${imageId}`); | ||
| return response; | ||
| }, | ||
| }; | ||
| Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,44 @@ | ||
| import app from "../../leonardo_ai.app.mjs"; | ||
|  | ||
| export default { | ||
| key: "leonardo_ai-unzoom-image", | ||
| name: "Unzoom Image", | ||
| description: "Creates an unzoom variation for a generated or variation image using Leonardo AI's unzoom API. [See the documentation](https://docs.leonardo.ai/reference/createvariationunzoom)", | ||
| version: "0.0.1", | ||
| type: "action", | ||
| props: { | ||
| app, | ||
| imageId: { | ||
| type: "string", | ||
| label: "Image ID", | ||
| description: "The ID of the image to create an unzoom variation for. This should be a previously generated or variation image ID.", | ||
| }, | ||
| isVariation: { | ||
| type: "boolean", | ||
| label: "Is Variation", | ||
| description: "Whether the image is a variation image.", | ||
| default: false, | ||
| }, | ||
| }, | ||
| async run({ $ }) { | ||
| const { | ||
| imageId, | ||
| isVariation, | ||
| } = this; | ||
|  | ||
| const data = { | ||
| id: imageId, | ||
| isVariation, | ||
| }; | ||
|  | ||
| const response = await this.app._makeRequest({ | ||
| $, | ||
| method: "POST", | ||
| path: "/variations/unzoom", | ||
| data, | ||
| }); | ||
|  | ||
| $.export("$summary", `Successfully created unzoom variation for image ID: ${imageId}`); | ||
| return response; | ||
| }, | ||
| }; | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Validate size vs. image count before calling the API
Enforce “if width or height > 768, numImages must be 1–4” to prevent API errors.
async run({ $ }) { const { prompt, modelId, width, height, numImages, guidanceScale, numInferenceSteps, seed, } = this; + if ((width > 768 || height > 768) && numImages > 4) { + throw new Error("When Width or Height exceeds 768, Number of Images must be between 1 and 4."); + }Also applies to: 78-88
🤖 Prompt for AI Agents