Automated AI Content Generation with Replicate Polling - n8n Workflow

Use this robust n8n workflow to automate text-to-image or content generation via the Replicate API. Features intelligent status 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?

Creative Professionals: Users needing to rapidly prototype visuals or content using AI models.
Developers: Those who need a production-ready template for integrating asynchronous API calls (like Replicate predictions) into their applications.
n8n Users: Individuals looking for advanced examples of robust looping and flow control within an n8n workflow.
Automation Specialists: Anyone leveraging n8n to connect AI services without custom middleware.

Overview

Generating complex AI content often requires asynchronous processes, where an initial request starts the job, and subsequent calls must poll the API until the result is ready. This specific n8n workflow solves this complexity by providing a ready-to-use, robust structure for interacting with the Replicate API's prediction endpoint.

This powerful n8n template handles authentication, sets all necessary generation parameters (like prompt, size, and model specifics), initiates the request, and then implements a flow control loop with built-in delays and conditional logic. This ensures that the n8n execution context waits appropriately for the content to be generated, handles potential failures, and provides a clear, structured JSON output containing the result URL or detailed error messages. Utilizing this n8n node structure guarantees reliable AI automation.

How it Works

The execution of this n8n workflow starts with the Manual Trigger, designed for testing or immediate execution.


  1. Configuration: The workflow first runs the 'Set API Token' n8n node, injecting your required Replicate API key. Next, the 'Set Other Parameters' n8n node defines all model inputs, including the text prompt and various technical parameters (like width, height, seed, and aspect ratio).

  2. Prediction Initiation: The 'Create Other Prediction' n8n node (an HTTP Request) sends a POST request to Replicate, initiating the content generation. It passes all parameters and uses the Bearer token for authentication, returning an initial prediction ID.

  3. Polling Loop Entry: The flow enters a monitoring loop, starting with the 'Log Request' n8n node for tracking, followed by the 'Wait 5s' n8n node.

  4. Status Check: The 'Check Status' n8n node polls the Replicate API using the prediction ID to retrieve the current status (e.g., 'processing', 'succeeded', 'failed').

  5. Conditional Routing: The 'Is Complete?' n8n node checks if the status is 'succeeded'. If successful, it proceeds to 'Success Response'. If not, the 'Has Failed?' n8n node checks for 'failed' status, routing errors to 'Error Response'.

  6. Retries: If the generation is still running, the flow uses the 'Wait 10s' n8n node to pause before looping back to 'Check Status', effectively creating a reliable retry mechanism. This logic is crucial for any asynchronous n8n workflow.

  7. Final Output: Upon completion or failure, the appropriate 'Set' n8n node formats a clean JSON output, which is then finalized by the 'Display Result' node.

Installation Guide

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


  1. Import the n8n Workflow: Copy the provided JSON data and paste it into your n8n instance using the 'New' menu and selecting 'Import from JSON'.

  2. Obtain Replicate Credentials: Sign up for an account at Replicate and retrieve your API token.

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

  4. Customize Parameters: Review the 'Set Other Parameters' n8n node. Adjust the prompt value and any other generation settings (like width, height, or seed) to suit your needs.

  5. Activate and Test: Activate the n8n workflow and click 'Execute Workflow' on the 'Manual Trigger' n8n trigger node to run a test generation. Monitor the logs for debugging or success output.

Node Details

This n8n template utilizes several critical n8n node types to achieve robust asynchronous processing:

Manual Trigger: This is the starting n8n trigger node. It initiates the entire n8n workflow execution, typically used for immediate testing or scheduled runs.
Set (API Token & Parameters): These n8n nodes are fundamental for data manipulation. 'Set API Token' stores the secret key, and 'Set Other Parameters' dynamically defines all input required by the Replicate API request body, including the default prompt: "Create something amazing".
Code (Log Request): A custom n8n node used for logging metadata (like prediction ID and timestamp) to aid in monitoring and debugging the long-running n8n workflow.
HTTP Request (Create Other Prediction): This n8n node sends the initial request to Replicate's API. It is configured to use the Bearer token authentication from the previous 'Set' node.
Wait: Used twice ('Wait 5s' and 'Wait 10s'). This essential n8n node pauses the execution flow, preventing excessive polling and adhering to API rate limits during the asynchronous generation process.
HTTP Request (Check Status): This n8n node is the core of the polling loop. It dynamically constructs a URL using the prediction ID received from the 'Create Other Prediction' node to check the current generation status.
If (Is Complete? & Has Failed?): These flow control n8n nodes manage the execution path based on the API response status, ensuring the n8n workflow handles success, failure, or continued processing correctly.
Set (Success Response & Error Response & Display Result): These final 'Set' n8n nodes ensure the output data is formatted clearly, providing the resulting content URL or a detailed error message, making this n8n workflow highly actionable.

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*