AI Image Generation via Replicate API Polling - n8n Workflow

Automate AI image generation using the Replicate API and powerful n8n workflow polling logic. This detailed guide covers setup, status checks, error handling, and customization for n8n templates.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • AI Developers and artists needing scalable image generation automation.

  • Users who require complex, asynchronous API status monitoring in an n8n workflow.

  • Anyone looking for robust n8n templates for integrating with third-party AI services.

  • Technical users aiming to customize and leverage the specific parameters of the 3rd Moises Generator model.

Overview

Integrating with generative AI models like those hosted on Replicate often requires managing asynchronous job submissions and polling for status updates. This specialized n8n workflow template solves that challenge entirely. When you initiate the process via the n8n trigger, the system submits a request to the Replicate API, then enters an intelligent monitoring loop. This robust logic, built using multiple n8n node types, ensures that your automation does not terminate until the image generation is complete (succeeded or failed). This powerful n8n workflow is highly customizable, allowing adjustment of critical parameters like prompts, image dimensions, and quality settings defined in the Set n8n node, making it a production-ready solution for your creative automation needs.

How it Works

The entire process is initiated by the Manual Trigger, which acts as the starting n8n trigger.


  1. Configuration: The workflow first runs two Set n8n nodes: 'Set API Token' (where you must input your Replicate key) and 'Set Other Parameters', defining the specific inputs for the 3rdmoisesgeneratoroldversion model, including the text prompt, image dimensions, and seed.

  2. Prediction Request: The 'Create Other Prediction' HTTP Request n8n node submits a POST request to Replicate to start the AI generation job. This returns a Prediction ID.

  3. Logging and Delay: The 'Log Request' Code n8n node records the transaction details, followed by a 'Wait 5s' n8n node to give the model time to initialize.

  4. Status Polling Loop: The 'Check Status' HTTP Request n8n node polls the Replicate API using the Prediction ID to retrieve the current status.

  5. Flow Control: The 'Is Complete?' If n8n node checks if the status is 'succeeded'. If true, it routes to 'Success Response'. If false, it checks the 'Has Failed?' If n8n node. If the status is 'failed', it routes to 'Error Response'.

  6. Retry Mechanism: If the status is neither 'succeeded' nor 'failed' (meaning it's still processing), the flow enters the 'Wait 10s' n8n node and then loops back to 'Check Status'. This continuous polling ensures the n8n workflow patiently waits for completion.

  7. Final Output: Based on the outcome, the data is structured by either the 'Success Response' or 'Error Response' Set n8n node before being finalized by the 'Display Result' Set n8n node.

Installation Guide

To utilize this 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 'Import Workflow' function.

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

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

  4. Customize Parameters: Navigate to the 'Set Other Parameters' n8n node. Here you can adjust the prompt, width, height, seed, and other model-specific configurations to tailor the AI output.

  5. Execute: Click the 'Manual Trigger' n8n trigger node and run the workflow either manually or activate it to respond to other system triggers.

Node Details


  • Manual Trigger: The starting n8n trigger point for executing the generation process.

  • Set API Token (Set n8n node): Securely stores the Replicate API key, which is later referenced by the HTTP Request n8n nodes using an expression.

  • Set Other Parameters (Set n8n node): Defines all input parameters for the AI model, including prompt (e.g., 'Create something amazing'), width (512), height (512), and numinferencesteps (28).

  • Create Other Prediction (HTTP Request n8n node): Sends the initial request to Replicate's /v1/predictions endpoint. It uses dynamic JSON body construction based on the input parameters and includes the Bearer token in the Authorization header.

  • Log Request (Code n8n node): A utility n8n node used for logging important metadata like prediction ID and timestamps, aiding in debugging and monitoring the n8n workflow execution.

  • Wait 5s / Wait 10s (Wait n8n nodes): These n8n nodes implement timed delays, crucial for effective polling of the asynchronous Replicate job.

  • Check Status (HTTP Request n8n node): Polls the specific prediction endpoint using the retrieved ID to check the job status (e.g., processing, succeeded, failed).

  • Is Complete? / Has Failed? (If n8n nodes): Core flow control n8n nodes that manage the polling loop and determine if the workflow should exit successfully, exit with an error, or continue waiting.

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*