AI Image Generator via Replicate Polling Loop - n8n Workflow

Generate high-quality images using the cyberrealistic-pony-v125 model on Replicate. This automated n8n workflow features status 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?


  • Automation experts looking for robust n8n templates for AI inference.

  • Developers needing a ready-made n8n workflow to integrate Replicate's image generation models.

  • Users who require complex polling logic within their n8n projects.

  • Anyone aiming to streamline the creation of AI assets without custom coding.

Overview

This n8n workflow provides a production-ready solution for asynchronous AI image generation using the Replicate API and the powerful 0xdino/cyberrealistic-pony-v125 model. Since AI generation is an asynchronous process, this n8n template utilizes sophisticated core logic flow control, specifically a polling loop with wait nodes, to continuously check the status of the prediction until it succeeds or fails. By implementing this robust structure within the n8n node sequence, you ensure reliability, error resilience, and timely retrieval of the final high-resolution image URL. This detailed n8n workflow handles everything from authentication and parameter configuration to logging and structured success/failure responses. Using this n8n automation simplifies the integration of advanced generative AI into any application.

How it Works


  1. The n8n workflow starts with the Manual Trigger, the designated n8n trigger to initiate the image generation.

  2. The Set API Token n8n node securely sets your Replicate API key.

  3. The Set Other Parameters n8n node defines the image inputs, including the positive prompt, negative prompt, dimensions (768x1152), and technical specifications (CFG, steps).

  4. The Create Other Prediction HTTP Request n8n node sends the request to the Replicate API, initiating the job and returning a unique prediction ID.

  5. The Log Request code n8n node records the prediction ID for monitoring purposes.

  6. A continuous polling loop begins: first, the Wait 5s n8n node introduces an initial delay.

  7. The Check Status HTTP Request n8n node uses the prediction ID to query the status of the generation job.

  8. The Is Complete? n8n node checks if the status is 'succeeded'. If true, the n8n workflow branches to Success Response.

  9. If the job is not complete, the Has Failed? n8n node checks for a 'failed' status. If failed, it moves to Error Response.

  10. If the job is still running (neither succeeded nor failed), the n8n workflow uses the Wait 10s n8n node to pause before looping back to Check Status, ensuring the process continues until completion. This efficient polling structure is key to this n8n template.

  11. Finally, either the Success Response (providing the image URL) or Error Response prepares the data for the final Display Result n8n node output.

Installation Guide


  1. Import the n8n Workflow: Copy the provided JSON data and import it directly into your n8n instance via the Workflows section to create this new n8n workflow.

  2. Replicate Account Setup: Obtain your personal API token from your Replicate account.

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

  4. Adjust Parameters: Review the Set Other Parameters n8n node. You must customize the prompt and negativeprompt variables to define the image you want to generate. You can also adjust technical parameters like width, height, and steps.

  5. Test the n8n Trigger: Click the Manual Trigger n8n node to execute the n8n workflow and verify that the image generation and polling logic function correctly.

Node Details

Manual Trigger: The initial n8n trigger that starts the execution of this n8n workflow, ideal for testing or scheduled runs.
Set API Token (Set n8n node): Stores the sensitive Replicate API key as an item variable (apitoken) for use in subsequent HTTP calls.
Set Other Parameters (Set n8n node): Configures all necessary input variables for the image generation model, including the descriptive prompt and technical settings like steps (40) and dimensions (768x1152).
Create Other Prediction (HTTP Request n8n node): Initiates the asynchronous generation task on Replicate.
Function: POST request to https://api.replicate.com/v1/predictions.
Key Configuration: Uses the api
token in the Authorization header (Bearer {{ $json.api_token }}) and includes the model version ID and all configured parameters in the JSON body.
Log Request (Code n8n node): A utility n8n node that logs generation details, prediction IDs, and timestamps to the console for monitoring the n8n workflow execution.
Wait 5s / Wait 10s (Wait n8n node): Implements necessary delays in the n8n workflow to prevent excessive API calls while waiting for the model to process the image.
Check Status (HTTP Request n8n node): Polls the Replicate API using the specific prediction ID to retrieve the current status (starting, processing, succeeded, or failed). This is central to the polling logic of this n8n template.
Is Complete? / Has Failed? (If n8n node): Core logic flow control n8n nodes that route the n8n workflow based on the received generation status, ensuring successful results are processed and failures are handled gracefully.

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*