AI Image Generation with Replicate Prunaai Flux.1 Dev - n8n Workflow

Automate asynchronous AI image generation using the Prunaai Flux.1 Dev model via Replicate. This powerful n8n workflow implements an efficient polling loop to manage job status, providing reliable results for developers and content creators looking for powerful n8n templates.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Automation specialists seeking advanced n8n workflow examples involving asynchronous API interactions.
Developers who need reliable image generation capabilities integrated into their backend processes.
Content creators looking to rapidly generate assets using cutting-edge models like Prunaai Flux.1 Dev.
Users searching for high-quality n8n templates for AI integration.

Overview

Generating complex AI images is often an asynchronous task, meaning the initial API call only starts the job and doesn't return the final result immediately. This requires continuous 'polling' of the API until the job completes. This expert n8n workflow solves this complexity by providing a robust, self-contained polling mechanism specifically designed for the Replicate API and the Prunaai Flux.1 Dev model.

By utilizing this n8n template, users can reliably request image generation, pause execution for a short period using the Wait n8n node, and then check the status repeatedly until the output is ready. This seamless automation is crucial for building stable, professional AI applications using n8n.

How it Works

This automation follows a precise sequence to ensure the asynchronous AI job is managed correctly:


  1. Initialization: The n8n workflow is started using the 'On clicking 'execute'' manual n8n trigger. This is immediately followed by the 'Set API Key' n8n node, which securely establishes the Replicate API key for subsequent HTTP requests.

  2. Creation Request: The 'Create Prediction' HTTP Request n8n node sends a POST request to the Replicate predictions endpoint, initiating the image generation using the specified prompt and model (prunaai/flux.1-dev).

  3. ID Extraction: The 'Extract Prediction ID' Code n8n node captures the unique predictionId from the initial response. This ID is essential for tracking the job status.

  4. Polling Start: The workflow enters a loop, starting with the 'Wait' n8n node, which pauses execution for 2 seconds to avoid overwhelming the API and allow the model time to process.

  5. Status Check: The 'Check Prediction Status' HTTP Request n8n node uses the extracted predictionUrl (which includes the predictionId) to retrieve the current status of the job.

  6. Loop Condition: The 'Check If Complete' IF n8n node evaluates the job status. If the status is equal to succeeded, the n8n workflow proceeds to process the result. If the status is anything else (e.g., processing), the flow loops back to the 'Wait' n8n node, repeating the polling cycle.

  7. Final Output: Once successful, the 'Process Result' Code n8n node extracts the crucial information, including the final image URL, making the result easily accessible for subsequent downstream n8n nodes or systems.

Installation Guide

To deploy this expert n8n workflow and start generating images, follow these steps:


  1. Import the JSON: Copy the provided JSON code and import it directly into your n8n instance via the 'New' menu > 'Import from JSON'.

  2. Obtain API Key: Register for an account with Replicate and obtain your personal API key.

  3. Configure Credentials: Locate the 'Set API Key' n8n node (ID: 3f36e2fc-a51e-4727-a049-7c826f3e7e3b). Replace the placeholder text YOURREPLICATEAPI_KEY with your actual Replicate token.

  4. Configure Prompt: In the 'Create Prediction' HTTP Request n8n node, modify the prompt value within the JSON body to specify the image content you wish to generate.

  5. Activate and Run: Save the n8n workflow, activate it, and execute the manual n8n trigger to test the image generation process.

Node Details

On clicking 'execute' (Manual Trigger): Serves as the starting point, initiating the entire n8n workflow execution upon user command.
Set API Key (Set n8n node): Essential for security, it dynamically sets the replicateapikey variable, ensuring the authorization header is correctly built for Replicate API access.
Create Prediction (HTTP Request n8n node): Sends the initial asynchronous request to Replicate. Key configuration includes using the POST method, setting the authorization header to use the Bearer token, and specifying the prunaai/flux.1-dev model version.
Extract Prediction ID (Code n8n node): Uses JavaScript to parse the API response, extracting the unique job identifier (predictionId) and constructing the subsequent API polling URL.
Wait (Wait n8n node): Implements a necessary 2-second delay in the polling loop, preventing rate limiting and ensuring efficient resource usage within the n8n workflow.
Check Prediction Status (HTTP Request n8n node): The core of the polling logic. It continuously checks the status of the job using the dynamic prediction URL and the authentication header defined in the previous n8n node.
Check If Complete (IF n8n node): Controls the flow. It directs the n8n workflow to the final processing step if the status is succeeded, otherwise, it loops back to the 'Wait' n8n node.
Process Result (Code n8n node): The final processing step. It cleanly outputs the key data fields, most importantly the generated image URL, making the result of this n8n template usable.

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*