Image Generation Using Replicate's Custom Paige AI Model - n8n Workflow

Leverage this custom n8n workflow to generate stylized images using the Paigedutcher2/Paige model on Replicate. Includes reliable polling logic for asynchronous AI tasks.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Developers integrating custom AI models into their applications.

  • Content creators needing automated, stylized image generation.

  • Users looking for advanced examples of Replicate API polling logic implemented in an n8n workflow.

  • Automation specialists building complex, multi-step n8n templates.

Overview

This powerful n8n workflow addresses the challenge of integrating asynchronous AI generation services like Replicate. When dealing with sophisticated models, such as the paigedutcher2/paige model used here for custom image generation, the initial API request only starts the job. This specific n8n workflow template handles the full lifecycle: initiating the prediction, waiting strategically, and securely polling the status until the final output is ready. This design ensures reliable execution within the n8n environment, transforming a complex, multi-step API interaction into a seamless, fully automated n8n node chain. Setting up this n8n workflow requires only your Replicate API key.

How it Works


  1. The n8n trigger, 'On clicking 'execute'', manually starts the generation process.

  2. The 'Set API Key' n8n node securely defines the required Replicate API key, which is used for all subsequent authenticated requests.

  3. The 'Create Prediction' http request n8n node initiates the image generation task on Replicate via a POST request, passing critical parameters like prompt, seed, width, and height to the custom AI model.

  4. The 'Extract Prediction ID' code n8n node captures the unique prediction ID and the polling URL from the initial response, preparing for the asynchronous monitoring phase.

  5. The n8n workflow enters a critical polling loop. It first uses the 'Wait' n8n node to pause for 2 seconds, preventing rapid, unnecessary API calls.

  6. The 'Check Prediction Status' http request n8n node then polls the Replicate API using the extracted URL and the authentication header to check the job status.

  7. The 'Check If Complete' if n8n node determines if the job status equals 'succeeded'.

  8. If successful, the n8n workflow exits the loop, and the 'Process Result' code n8n node extracts and formats the final generated output URLs. If the job is still running (or failed), the n8n workflow loops back to the 'Wait' n8n node to continue polling, ensuring reliable job completion.

Installation Guide


  1. Import the n8n template: Copy the provided JSON code and import it directly into your self-hosted or cloud n8n instance.

  2. Set API Key: Locate the 'Set API Key' n8n node. In the parameters, replace the placeholder YOURREPLICATEAPI_KEY with your actual Replicate API key.

  3. Configure Prompt: Examine the 'Create Prediction' http request n8n node. Modify the JSON body to include the desired prompt and specific output dimensions (width, height, etc.) tailored for the Paigedutcher2 model.

  4. Execution: Use the 'On clicking 'execute'' n8n trigger to test the n8n workflow. For production use, you may replace the manual n8n trigger with a webhook or schedule.

Node Details

Manual Trigger (n8n trigger): Starts the n8n workflow execution upon manual click.
Set API Key (n8n node): A crucial Set n8n node that securely stores the Replicate API key as an item variable for easy and secure use in subsequent http requests.
Create Prediction (HTTP Request n8n node): Initiates the asynchronous task by sending a POST request to Replicate's /predictions endpoint. Key configuration includes using generic HTTP header authentication (Bearer token) and a detailed JSON body defining the AI model version and input parameters.
Extract Prediction ID (Code n8n node): Custom code snippet to parse the initial response and extract the unique predictionId and the specific predictionUrl required for polling the status.
Wait (n8n node): Enforces a 2-second delay in the polling loop, preventing API rate limits and optimizing the n8n workflow efficiency.
Check Prediction Status (HTTP Request n8n node): Repeatedly calls the prediction URL using the Replicate API key to monitor the job status.


  • Check If Complete (If n8n node): The core control flow n8n node. It checks if the status field returned by the polling request equals 'succeeded'. If true, the workflow proceeds; otherwise, it loops back to the 'Wait' n8n node.

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*