AI Image Generation Workflow using Replicate and Polling Logic - n8n Workflow

Deploy a robust n8n workflow to generate custom AI images using the Replicate API and the creativeathive/lemaar-doorhandle-newset model. This n8n workflow includes built-in polling, error handling, and structured results.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Developers requiring automated AI asset creation using n8n.

  • Users looking for advanced n8n templates featuring complex API polling and retry loops.

  • Digital marketers needing custom image generation at scale.

  • Technical users leveraging the Replicate platform for custom models like lemaar-doorhandle-newset.

Overview

Generating large AI images often requires asynchronous processing, meaning you must initiate a job and then continuously check its status until completion. This complex process is streamlined by this powerful n8n workflow. It solves the challenge of integrating Replicate's asynchronous API into a linear automation flow. The n8n template ensures that after initiating the prediction, the automation doesn't fail; instead, it enters an intelligent polling loop using the Wait n8n node and If n8n node logic, waiting for success or failure. This setup is highly resilient and production-ready, making it an excellent example of robust cloud-based automation using n8n.

How it Works

The n8n workflow begins execution immediately upon activation of the Manual Trigger, which acts as the initial n8n trigger.


  1. Configuration: The workflow first runs the 'Set API Token' n8n node to define the Replicate API key, followed by the 'Set Other Parameters' n8n node, where parameters like prompt, width, and height for the creativeathive/lemaar-doorhandle-newset model are defined.

  2. Initiate Generation: The 'Create Other Prediction' n8n node (an HTTP Request) sends a POST request to the Replicate API, starting the image generation process and receiving a prediction ID.

  3. Logging & Initial Wait: The 'Log Request' n8n node records the prediction ID for monitoring, followed by an initial 'Wait 5s' n8n node.

  4. Polling Loop: The 'Check Status' n8n node sends a GET request to Replicate to retrieve the current prediction status based on the ID.

  5. Decision Branching: The 'Is Complete?' n8n node checks if the status is 'succeeded'. If true, it moves to 'Success Response'. If false, it proceeds to the 'Has Failed?' n8n node.

  6. Failure/Retry: If 'Has Failed?' finds the status is 'failed', the workflow moves to 'Error Response'. If the status is still 'processing' or 'starting', the logic routes to 'Wait 10s', which delays the execution before repeating the 'Check Status' step. This creates a resilient loop crucial for reliable asynchronous operation within the n8n workflow.

  7. Final Output: Both success and error branches terminate at the 'Display Result' n8n node, providing a structured JSON output detailing the result URL or error message.

Installation Guide

To use this powerful n8n template, follow these steps:


  1. Import the JSON: Copy the provided n8n workflow JSON structure and import it into your n8n instance using the 'New' > 'Import from JSON' option.

  2. Replicate Credentials: Obtain your API token from Replicate.com.

  3. Configure API Token Node: Locate the 'Set API Token' n8n node. Replace the placeholder value YOURREPLICATEAPI_TOKEN with your actual Replicate API key.

  4. Customize Parameters: Navigate to the 'Set Other Parameters' n8n node. Here you can adjust the prompt, width, height, and other model-specific inputs relevant to the creativeathive/lemaar-doorhandle-newset model.

  5. Activate and Test: Activate the n8n workflow and click 'Execute Workflow' or the 'Manual Trigger' n8n trigger to test the image generation process.

Node Details

Manual Trigger (n8n trigger): Initiates the flow execution. Perfect for testing or manual generation requests.
Set API Token (n8n node): Securely stores the Replicate API token, which is used for authorization headers in subsequent HTTP requests.
Set Other Parameters (n8n node): Centralizes all input parameters needed for the creativeathive/lemaar-doorhandle-newset model, including dynamic values like the prompt and image dimensions.
Create Other Prediction (HTTP Request n8n node): This is the core action that sends the generation request to https://api.replicate.com/v1/predictions. It uses the Bearer token derived from the setup steps.
Log Request (Code n8n node): A utility n8n node that logs key request details (like prediction ID) for debugging and monitoring the n8n workflow execution.
Wait 5s / Wait 10s (Wait n8n node): Critical components of the polling loop, providing timed delays between status checks to prevent API throttling and allow processing time.
Check Status (HTTP Request n8n node): Periodically checks the status endpoint of the prediction ID to monitor job progress.
Is Complete? / Has Failed? (If n8n node): The flow control logic of this n8n workflow. It directs the execution path based on whether the AI generation job has succeeded, failed, or is still running.


  • Success Response / Error Response (Set n8n node): Formats the final, clean JSON response data, including the output URL upon success or detailed error messages upon failure.

Related n8n Workflows

Free

Nodes: 7 Nodes
Updated: December 26 2025
View all
Created by

Building AI Agents and Automations | Growth Marketer | Entrepreneur | Book Author & Podcast Host If you need any help with Automations, feel free to reach out via linkedin: https://www.linkedin.com/in/yaronbeen/ And check out my Youtube channel: https://www.youtube.com/@YaronBeen/videos

Featured*