Realistic AI Portrait Generation using Replicate Polling Loop - n8n Workflow

Automate professional AI image generation using the CyberRealistic Pony v36 model via Replicate. This robust n8n workflow template features an intelligent status polling loop for reliable results.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

AI artists and content creators needing production-ready image generation at scale.
Developers building asynchronous integrations that require intelligent status polling within an n8n workflow.
Users seeking robust n8n templates for generative AI and complex API interaction.
Anyone looking to leverage the power of the CyberRealistic Pony model using a managed n8n node structure.

Overview

Generating complex AI outputs, especially high-resolution images, is often an asynchronous process requiring polling to determine completion. This specialized n8n workflow solves this by implementing a reliable, production-ready polling loop leveraging the Replicate API. This n8n workflow is pre-configured to utilize the powerful 0xdino/cyberrealistic-pony-semireal-v36 model, allowing users to define a detailed prompt and receive a high-quality, photo-realistic image URL upon completion.

By using this dedicated n8n template, users avoid common pitfalls like timeouts and ensure proper error handling, making the integration of cutting-edge AI image generation seamless within their broader automation strategies. Every n8n node is configured for stability and performance.

How it Works

The process begins with the Manual Trigger n8n trigger, initiating the automation flow.


  1. Initialization: The n8n workflow first executes the 'Set API Token' n8n node to securely configure the Replicate API key. Following this, the 'Set Other Parameters' n8n node injects critical inputs (like prompt, width, height, and generation settings like cfg and steps) into the data stream.

  2. Creation Request: The 'Create Other Prediction' n8n node (an HTTP Request) sends a POST request to Replicate to start the generation process, receiving a prediction ID.

  3. Logging: The 'Log Request' n8n node logs the prediction ID for auditing and monitoring.

  4. Polling Loop: The n8n workflow enters a control loop starting with a 'Wait 5s' n8n node, followed by the 'Check Status' n8n node, which polls Replicate using the prediction ID.

  5. Status Check: The 'Is Complete?' n8n node checks if the status is 'succeeded'. If not successful, the 'Has Failed?' n8n node checks for failure.

  6. Retry Logic: If the status is still 'processing' or 'starting', the workflow executes 'Wait 10s' and loops back to 'Check Status', implementing intelligent retry logic inherent to this n8n template.

  7. Final Response: If 'succeeded', the 'Success Response' n8n node formats the output URL. If 'failed', the 'Error Response' n8n node captures the error message. Both paths converge at the 'Display Result' n8n node, providing a structured JSON response to the user.

Installation Guide

To deploy this powerful n8n workflow, follow these steps:


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

  2. Acquire Replicate API Key: Register or log in to Replicate and obtain your personal API token.

  3. Configure Credentials: Locate the 'Set API Token' n8n node (position: -608, -80). Replace the placeholder value YOURREPLICATEAPITOKEN with your actual Replicate API key.

  4. Customize Parameters (Optional): Open the 'Set Other Parameters' n8n node. Here you can adjust the image prompt, width, height, and other generation settings like the negativeprompt to tailor the output of this n8n workflow.

  5. Activate and Run: Set the n8n workflow to 'Active' and execute it using the 'Manual Trigger' n8n trigger to test the image generation.

Node Details

Manual Trigger (n8n trigger): Serves as the initiation point for executing this n8n workflow, ideal for testing and single runs.
Set API Token (n8n node): Essential initialization step. Stores the required Replicate API token as a variable (apitoken) for subsequent secure API calls.
Set Other Parameters (n8n node): Central configuration point. It defines all parameters, including the highly detailed prompt, dimensions (width, height), and sampling details, which are dynamically passed to the Replicate API.
Create Other Prediction (HTTP Request n8n node): This is the core action n8n node. It sends the generation request to Replicate using the configured inputs and authenticates using the api
token via the 'Authorization' header.
Check Status (HTTP Request n8n node): Responsible for the polling mechanism. It periodically queries Replicate using the prediction ID to retrieve the current status of the image generation job.
Is Complete? / Has Failed? (If n8n nodes): These n8n nodes manage the flow control, routing the data based on the prediction status ('succeeded', 'failed', or still processing).


  • Wait 5s / Wait 10s (Wait n8n nodes): Used within the asynchronous loop to throttle API polling requests, preventing rate limiting and optimizing resource usage within the n8n workflow.

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*