Black Forest Labs Flux Dev Image Generator using Replicate API - n8n Workflow

Use this robust n8n workflow to generate high-quality images using the Black Forest Labs Flux Dev model on Replicate. Customize prompts, handle status polling, and manage errors automatically in n8n.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Developers seeking robust AI image generation infrastructure using n8n.
Agencies needing repeatable and scalable image creation n8n templates.
Users who want to automate asynchronous API calls with built-in retry logic in an n8n workflow.
Creators looking to integrate state-of-the-art AI image generation models like Flux Dev into their application.

Overview

This powerful n8n workflow solves the complexity of integrating asynchronous AI APIs, specifically Replicate, for image generation. The flux-dev model from Black Forest Labs is highly capable of turning text prompts into stunning visuals. Since Replicate processes image generation asynchronously, this n8n template includes essential logic for status checking (polling), ensuring the application waits patiently and correctly before delivering the final image URL. It provides a reliable and production-ready structure for integrating advanced AI capabilities into any larger n8n automation pipeline. Utilizing the n8n node structure, this n8n workflow minimizes manual intervention and handles potential delays gracefully, making it an excellent example of resilient n8n automation.

How it Works

The process starts with the Manual Trigger n8n trigger node. First, the user defines the essential configuration details. The Set API Token n8n node stores the required Replicate API authentication, followed by the Set Image Parameters n8n node which customizes the AI input (like the image prompt and aspect ratio). Next, the Create Image Prediction HTTP Request n8n node sends the initial generation command to the Replicate API, receiving an asynchronous prediction ID. After logging the request details, the n8n workflow initiates a polling loop. It waits for 5 seconds (Wait 5s n8n node) and then checks the prediction status using the Check Status HTTP Request n8n node.

The Is Complete? If n8n node routes the flow based on the returned status. If the status is 'succeeded', the n8n workflow moves to the Success Response n8n node to finalize the output. If not, the Has Failed? If n8n node checks for hard errors. If the image is still pending (neither succeeded nor failed), the n8n workflow uses the Wait 10s n8n node before looping back to Check Status, creating a resilient retry mechanism until the image is successfully generated or an error occurs.

Installation Guide

To use this n8n workflow template effectively, follow these steps:


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

  2. API Key Setup: Obtain a Replicate API token by signing up at https://replicate.com and navigating to your account settings.

  3. Configure API Token: Locate the Set API Token n8n node and replace the placeholder value YOURREPLICATEAPITOKEN with your actual Replicate API token. This is crucial for authenticating the HTTP Request n8n node steps.

  4. Customize Parameters: Navigate to the Set Image Parameters n8n node. Here you can adjust key inputs such as the image prompt, aspectratio (default 1:1), and num_outputs.

  5. Activate and Test: Activate the n8n workflow and click the Manual Trigger n8n trigger node to initiate a test run. Monitor the execution to view the final image URL output in the last n8n node.

Node Details

Manual Trigger (n8n trigger): The starting n8n trigger for the automation. It allows for manual execution and testing of the image generation process.
Set API Token (n8n node): Stores the Replicate API key as an internal variable, securely passing it as an Authorization header (Bearer token) to API calls.
Set Image Parameters (n8n node): Defines all model inputs, including the core prompt, seed (-1 for random), aspectratio (1:1), and quality settings like outputquality (80).
Create Image Prediction (HTTP Request n8n node): Sends the asynchronous POST request to Replicate to initiate the generation process for the flux-dev model, returning a prediction ID.
Wait 5s / Wait 10s (n8n node): Used to implement necessary delays for the asynchronous API polling loop. These nodes prevent rapid, unnecessary polling.
Check Status (HTTP Request n8n node): Sends a GET request to the Replicate prediction status endpoint, using the ID from the previous step to check if the image job is 'succeeded', 'failed', or still 'processing'.


  • Is Complete? / Has Failed? (IF n8n node): Flow control logic that manages the polling loop and routes the n8n workflow to either success, failure, or back to the waiting state.

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*