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:
- Validates the generation ID is not empty
- Sends a delete request to the Leonardo AI API
- 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:
- Use List Generations to get all generations
- Filter for test generations (e.g., by prompt containing "test")
- Loop through test generations
- 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:
- List generations older than a certain date
- Optionally check if they're marked for deletion
- Delete generations meeting your criteria
- Log deleted generation IDs for audit trail
Delete After Download
Clean up after downloading images:
- Create Generation
- Wait for completion with Get Generation
- Download the generated images
- 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