AI Image Generation with Replicate Polling Loop - n8n Workflow

Automate AI image generation using Replicate’s Creativeathive Lemaar Door Blurrred model. This powerful n8n workflow template handles asynchronous generation and status polling.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Users needing to automate generation of creative assets via AI.

  • Developers leveraging the Replicate API for specialized AI models.

  • n8n users looking for advanced examples of asynchronous polling logic.

  • Teams integrating custom AI generation into production systems.

Overview

Generating complex AI outputs, such as high-resolution images, is often an asynchronous process. This means the initial request only provides a job ID, requiring continuous polling to check the completion status. This specialized n8n workflow expertly manages this challenge. By using a combination of HTTP Request, Code, Wait, and If logic, this n8n workflow template ensures reliable monitoring of the Creativeathive Lemaar Door Blurrred model on Replicate. The n8n node structure handles the API key setup, job creation, and the crucial polling loop, simplifying complex backend automation into a single, reliable n8n workflow.

How it Works

This n8n workflow starts with a manual n8n trigger for immediate testing. The process follows a clear sequence of steps designed for asynchronous API interaction:


  1. Setup and Trigger: The execution is manually initiated via the n8n trigger. An initial Set n8n node secures the necessary Replicate API key, preparing it for authorization.

  2. Prediction Creation: An HTTP Request n8n node sends a POST request to Replicate, initiating the generation process for the creativeathive/lemaar-door-blurrred model. This request includes essential parameters like prompt, seed, and dimensions.

  3. ID Extraction: A Code n8n node immediately extracts the unique predictionId and the initial status from the creation response. This ID is critical for the subsequent polling mechanism.

  4. Asynchronous Polling Loop: The n8n workflow enters a loop starting with a Wait n8n node, which pauses execution for 2 seconds to avoid overwhelming the Replicate API.

  5. Status Check: A second HTTP Request n8n node polls the specific prediction URL (using the extracted ID) to retrieve the current job status.

  6. Conditional Check (If n8n node): An If n8n node evaluates the returned status. If the status is 'succeeded', the n8n workflow proceeds to process the result. If the status is anything else (e.g., 'processing'), the flow loops back to the Wait n8n node to continue polling.

  7. Result Processing: Once the AI generation completes, a final Code n8n node processes the output, extracting the result URLs and metadata, finalizing the execution of this comprehensive n8n template.

Installation Guide


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

  2. API Key Setup: Locate the 'Set API Key' n8n node. Replace the placeholder value YOURREPLICATEAPI_KEY with your actual Replicate API key.

  3. Authentication: Ensure the 'Create Prediction' and 'Check Prediction Status' HTTP Request n8n node instances are correctly configured to use Generic Credentials via HTTP Header Auth, referencing the API key set in the previous n8n node.

  4. Customization: Review the 'Create Prediction' n8n node to adjust the prompt and other input values specific to your generation requirements.

  5. Execution: Use the manual n8n trigger to test and execute the n8n workflow.

Node Details

On clicking 'execute' (Manual Trigger): Serves as the initial n8n trigger, allowing for immediate testing and execution of the n8n workflow.
Set API Key (Set n8n node): Stores the private Replicate API key as an item variable, securely injecting it into subsequent requests.
Create Prediction (HTTP Request n8n node): The core request that utilizes the Replicate API to initiate the AI generation task for the specified model. It is a vital component of this n8n template.
Extract Prediction ID (Code n8n node): A custom n8n node that uses JavaScript to parse the initial response, extracting the unique job ID required for the polling process. This demonstrates advanced usage within an n8n workflow.
Wait (Wait n8n node): Crucial for rate limiting and asynchronous control, this n8n node pauses the execution for 2 seconds before each status check.
Check Prediction Status (HTTP Request n8n node): Polls the Replicate API using the prediction URL, checking the current status of the AI generation job.
Check If Complete (If n8n node): Provides the flow control logic for this n8n workflow, determining if the job is finished ('succeeded') or if the polling loop must continue.
Process Result (Code n8n node): Executes upon successful completion, cleaning and structuring the final AI output data before concluding the n8n workflow.

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*