AI Content Generation via Replicate API Polling - n8n Workflow

Use this powerful n8n workflow to automate AI content generation using the creativeathive/lemaar-door-urban model on Replicate. Features built-in API polling and robust error handling.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

AI Developers & Integrators: Users seeking pre-built n8n templates for asynchronous AI services. Creative Agencies: Teams needing to automate the creation of urban-themed digital assets using specific AI models. n8n Automation Specialists: Users who require a production-ready n8n workflow example demonstrating API polling logic. Technical Users: Individuals looking to integrate specialized AI models (like lemaar-door-urban) directly into their business processes using a custom n8n node setup.

Overview

This comprehensive n8n workflow is designed to manage the complexities of asynchronous AI generation requests via the Replicate API. Instead of simply sending a request and hoping for the best, this n8n automation template implements an intelligent polling mechanism. When the Manual Trigger starts the process, the system first sends the generation request to the creativeathive/lemaar-door-urban model and then enters a robust status checking loop. This ensures the workflow waits efficiently for the resource-intensive AI generation task to complete, whether it takes 5 seconds or 5 minutes. The structure of this n8n workflow includes built-in logging, parameter configuration, and clear success/error paths, making it a reliable and production-ready solution for integrating external AI models without needing a dedicated n8n node for Replicate.

How it Works

The n8n workflow begins with the Manual Trigger, activating the execution chain.


  1. Configuration: The flow first hits the Set API Token n8n node to define the necessary Replicate authentication key, followed by the Set Other Parameters n8n node, where all model inputs (like the prompt, image, and desired dimensions for the lemaar-door-urban model) are configured.

  2. Request Initiation: The Create Other Prediction n8n node, an HTTP Request node, sends a POST request to the Replicate API, initiating the AI generation job. This request uses the previously defined parameters and returns an initial prediction ID.

  3. Polling Loop: After a brief Wait 5s n8n node, the Check Status n8n node begins polling the Replicate API using the prediction ID.

  4. Flow Control: The Is Complete? n8n node checks if the job status is 'succeeded'. If not, the flow moves to the Has Failed? n8n node. If it has neither succeeded nor failed (meaning it's still processing), the flow loops back through the Wait 10s n8n node to retry the status check.

  5. Finalization: Once the Is Complete? n8n node confirms success, the result (including the generated content URL) is formatted by the Success Response n8n node. Failures are handled by the Error Response n8n node. Both paths terminate at the Display Result n8n node, providing a clear, structured JSON output for the user or the next n8n node in the chain.

Installation Guide

To deploy this powerful n8n workflow template, follow these steps:


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

  2. Obtain Credentials: You must have a Replicate account. Generate your API token from the Replicate dashboard.

  3. Configure API Token: Locate the Set API Token n8n node. Replace the placeholder value YOURREPLICATEAPI_TOKEN with your actual token.

  4. Review Parameters: Navigate to the Set Other Parameters n8n node. Here you can adjust the prompt, image, width, and other detailed settings relevant to the creativeathive/lemaar-door-urban model.

  5. Activation: Ensure the n8n workflow is saved and active. You can execute the flow by clicking the Manual Trigger n8n node to test the AI generation process.

Node Details

Manual Trigger (n8n trigger):
Function: Starts the n8n workflow execution upon user click.
Key Configuration: Simple, serves as the initial execution point for this n8n template.

Set API Token (n8n node):
Function: Securely defines the Replicate API token necessary for authentication.
Key Configuration: Sets the variable apitoken for use in subsequent HTTP Request nodes.

Set Other Parameters (n8n node):
Function: Configures the large set of input parameters required by the lemaar-door-urban model (e.g., prompt: "Create something amazing", image, width, height, etc.).
Key Configuration: Dynamically pulls the API token and sets default values for inputs like seed: -1, width: 512, and numoutputs: 1.

Create Other Prediction (HTTP Request n8n node):
Function: Sends the initial asynchronous request to Replicate to start the content generation job.
Key Configuration: Method: POST. URL: https://api.replicate.com/v1/predictions. Includes Authorization header (Bearer {{ $json.api_token }}) and a custom JSON body mapping all parameters.

Check Status (HTTP Request n8n node):
Function: Polls the Replicate API endpoint to check the current status of the prediction job using the prediction ID.
Key Configuration: Method: GET. URL: Dynamically constructed using the prediction ID from the previous request.

Is Complete? / Has Failed? (If n8n nodes):
Function: Provides flow control based on the prediction status (checks for 'succeeded' or 'failed').
Key Configuration: Conditional logic checking {{ $json.status }} against specific string values.

Wait 5s / Wait 10s (Wait n8n node):
Function: Introduces necessary delays in the polling loop to prevent overloading the Replicate API with requests. The 10-second wait facilitates reliable asynchronous handling within this n8n workflow structure.

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*