AI Content Generation using Replicate and Polling Loop - n8n Workflow

Automate AI content generation using the monexia/nietgoed model via Replicate. This n8n workflow template includes crucial polling logic and error handling for asynchronous tasks.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Developers seeking n8n templates for asynchronous API polling mechanisms.
Users looking to integrate the Monexia Nietgoed AI model into their backend systems.
Automation specialists needing a production-ready n8n workflow for AI content creation.
Anyone aiming to leverage the Replicate API within an n8n environment.

Overview

This n8n workflow provides a complete solution for interacting with asynchronous AI APIs, specifically demonstrating how to use the Monexia Nietgoed model hosted on Replicate for content generation. Since AI generation tasks can take time, this n8n workflow does not rely on a single request. Instead, it uses a powerful polling loop structure (Wait and If n8n nodes) to repeatedly check the status until the content is successfully generated. This robust design makes the n8n template ideal for production use where waiting is mandatory. Using this n8n template ensures reliable execution even for longer-running AI jobs.

How it Works

The n8n workflow begins with the Manual Trigger, which acts as the starting n8n trigger for immediate execution.


  1. Initialization: The n8n workflow first executes the "Set API Key" n8n node to define the Replicate API credential.

  2. Creation: The "Create Prediction" n8n node sends the initial POST request to Replicate, specifying the monexia/nietgoed model and the input prompt, which returns an immediate prediction ID.

  3. Extraction: The "Extract Prediction ID" Code n8n node captures the unique ID and constructs the prediction URL required for monitoring.

  4. Polling Loop Entry: The n8n workflow enters the polling sequence, starting with the "Wait" n8n node, which pauses execution for 2 seconds.

  5. Status Check: The "Check Prediction Status" HTTP Request n8n node queries the prediction URL using the prediction ID.

  6. Conditional Check: The "Check If Complete" If n8n node determines if the status is 'succeeded'. If true, the n8n workflow proceeds to output processing. If false, it loops back to the "Wait" n8n node to pause and recheck the status, ensuring the n8n workflow efficiently manages asynchronous tasks.

  7. Final Processing: The "Process Result" Code n8n node captures the final generated output and associated metadata when the process is complete, concluding this complex n8n automation.

Installation Guide

To deploy this n8n template successfully, follow these steps:


  1. Import: Copy the provided JSON data and use the "Import Workflow" function within your n8n instance.

  2. API Key Setup: Locate the "Set API Key" n8n node. Replace the placeholder YOURREPLICATEAPI_KEY with your actual Replicate API key. This is critical for the subsequent HTTP Request n8n nodes.

  3. Model Configuration: Review the "Create Prediction" n8n node (HTTP Request). Ensure the input parameters like prompt, seed, width, and height are configured correctly for the content you wish to generate.

  4. Run: Use the "On clicking 'execute'" n8n trigger node to manually start the n8n workflow. For production use, consider replacing this manual n8n trigger with a Cron or Webhook n8n trigger.

Node Details

This n8n workflow relies on several specialized n8n nodes for sequential execution and asynchronous handling:

On clicking 'execute' (Manual Trigger n8n trigger): Serves as the starting n8n trigger point for the n8n workflow, ideal for testing and manual initiation.
Set API Key (Set n8n node): Used to securely set the replicateapikey variable, which is referenced dynamically by the HTTP Request n8n nodes for API authentication.
Create Prediction (HTTP Request n8n node): Initiates the AI generation via Replicate's API using a POST method. Key configuration includes the use of Bearer authentication referencing the API key set by the previous n8n node, and specifying the target model version (b4eed8f86100995e0919dcf5e4af4eca54fc43ce72f4fd570e7d211cfe240b3d).
Extract Prediction ID (Code n8n node): A utility n8n node that parses the initial response to extract the unique prediction ID and constructs the necessary polling URL, which is vital for the rest of the n8n workflow logic.
Wait (Wait n8n node): Manages the polling interval, configured to pause the n8n workflow for 2 seconds between status checks, preventing API throttling and ensuring efficient task management within this n8n template.
Check If Complete (If n8n node): The core control flow n8n node that determines if the AI task status equals succeeded. This conditional logic governs the loop structure of the entire n8n workflow.


  • Process Result (Code n8n node): The final processing n8n node that formats and extracts the generated output and metadata once the 'succeeded' status is confirmed.

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*