Skip to main content

Delete Generation

Deletes a generation and its associated images from Leonardo AI.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.

Inputs

  • Connection Id (String) - Connection ID from the Connect node (optional if API Key credentials are provided directly).
  • Generation Id (String) - ID of the generation to delete.

Options

  • API Key - Leonardo AI API key (optional if using Connection ID).

Outputs

This node does not have outputs.

How It Works

The Delete Generation node permanently removes a generation from your account. When executed, the node:

  1. Validates the generation ID is not empty
  2. Sends a delete request to the Leonardo AI API
  3. Removes the generation and all associated images

Requirements

  • Valid Leonardo AI API key (via Connection ID or credentials)
  • Valid generation ID
  • Permission to delete the generation (must be the owner)

Error Handling

The node will return specific errors in the following cases:

  • Empty generation ID - "Generation ID cannot be empty. Please provide a valid generation ID."
  • API error - "Failed to delete generation. API error {status}: {details}"
  • Generation not found - API will return 404 if generation doesn't exist
  • Permission denied - API will return error if you don't own the generation

Usage Examples

Clean Up Test Generations

Delete generations created during testing:

  1. Use List Generations to get all generations
  2. Filter for test generations (e.g., by prompt containing "test")
  3. Loop through test generations
  4. Delete each one using Delete Generation

Delete Failed Generations

Remove generations that failed:

// After listing generations
const generations = $.generations;
const failedGenerations = generations.filter(gen =>
gen.status === 'FAILED'
);

// Loop through and delete each failed generation
failedGenerations.forEach(gen => {
// Use Delete Generation with gen.id
});

Automated Cleanup

Set up periodic cleanup of old generations:

  1. List generations older than a certain date
  2. Optionally check if they're marked for deletion
  3. Delete generations meeting your criteria
  4. Log deleted generation IDs for audit trail

Delete After Download

Clean up after downloading images:

  1. Create Generation
  2. Wait for completion with Get Generation
  3. Download the generated images
  4. Delete Generation to free up space

Usage Notes

  • Deletion is permanent and cannot be undone
  • All images associated with the generation are also deleted
  • The generation ID becomes invalid after deletion
  • Use caution when deleting - consider backing up important generations first
  • Useful for managing storage and keeping your account organized
  • Consider implementing confirmation logic before deletion
  • Failed deletions may indicate the generation was already deleted
  • You can only delete generations you own