Luma Photon Flash AI Image Generation via Replicate Polling - n8n Workflow

Use this n8n workflow template to reliably generate high-quality images with the Luma Photon Flash AI model via Replicate. Features asynchronous polling logic for long-running tasks.

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 automated, high-volume image generation.

  • Developers looking for robust n8n templates integrating asynchronous external APIs (like Replicate).

  • Technical users wanting an example of synchronous and asynchronous API handling within an n8n workflow.

Overview

Generating complex AI images often involves long processing times, requiring an asynchronous approach (polling) rather than a simple single request. This powerful n8n workflow addresses this challenge by meticulously setting up the API call to Replicate, extracting the job ID, and continuously polling the status until the image generation is complete (status: 'succeeded'). This reliable n8n workflow ensures you capture the final image output, making it an essential n8n templates example for handling demanding AI tasks. The setup is simple: provide your prompt and API key, and the rest of the automation handles the complex polling logic using several standard n8n node elements.

How it Works

This n8n workflow starts with the 'On clicking 'execute'' n8n trigger, designed for quick testing and manual runs.


  1. Setup: The flow first hits the 'Set API Key' n8n node, where you define your Replicate API key, ensuring all subsequent HTTP requests are authenticated.

  2. Create Prediction: The 'Create Prediction' n8n node sends a POST request to the Replicate predictions API, initiating the Luma Photon Flash generation task. It passes the prompt and desired configuration settings.

  3. Extract ID: The 'Extract Prediction ID' n8n node (a Code node) immediately parses the response JSON to extract the unique prediction ID and the polling URL, which are essential for tracking the job's status.

  4. Wait Period: The 'Wait' n8n node introduces a 2-second pause, preventing excessive API calls while the model processes the image.

  5. Check Status: The 'Check Prediction Status' n8n node performs a GET request to the extracted prediction URL, checking the current status of the job.

  6. Conditional Check: The 'Check If Complete' n8n node evaluates the response status. If the status is 'succeeded', the flow proceeds to process the result. If not, the n8n workflow loops back to the 'Wait' n8n node, continuing the polling cycle until completion.

  7. Process Result: Once complete, the 'Process Result' n8n node extracts the final image URL and relevant metadata, providing a clean, usable output item.

Installation Guide

To use this n8n workflow template, follow these steps:


  1. Import: Copy the provided JSON data and import it into your n8n instance.

  2. Replicate API Key: Locate the 'Set API Key' n8n node. Replace the placeholder value YOURREPLICATEAPI_KEY with your actual Replicate API token.

  3. Prompt Configuration: Review the 'Create Prediction' n8n node. Edit the jsonBody to update the prompt value with your desired image description, and adjust parameters like seed or weight as needed.

  4. Credentials: Although the API key is set directly in the flow for simplicity, ensure any other necessary HTTP generic credentials are set up if you adapt this n8n workflow for other services.

  5. Execution: Click 'Execute Workflow' (or 'Test Workflow') to run the entire n8n workflow and generate your first image.

Node Details

On clicking 'execute' (Manual Trigger): The starting n8n trigger for immediate execution, primarily used for testing and manual initiation of this n8n workflow.
Set API Key (Set Node): Used to securely define the replicateapikey variable, making it accessible as a bearer token in subsequent HTTP Request n8n node configurations.
Create Prediction (HTTP Request Node): Sends the initial POST request to Replicate, specifying the luma/photon-flash model and the input parameters (prompt, seed, weights).
Extract Prediction ID (Code Node): Crucial step that extracts the unique ID and constructs the necessary polling URL (predictionUrl) from the initial response body, enabling the asynchronous part of the n8n workflow.
Wait (Wait Node): Implements a 2-second delay between status checks, which is vital for preventing rate limiting during the polling phase of the n8n workflow.
Check Prediction Status (HTTP Request Node): The polling n8n node; it repeatedly calls the Replicate API using the prediction ID to fetch the current job status.
Check If Complete (IF Node): The core control flow n8n node, determining whether the workflow should proceed to 'Process Result' or loop back to 'Wait' based on whether the job status equals 'succeeded'.
Process Result (Code Node): Final processing n8n node that formats and extracts the generated image URL and cleanup metrics from the successful API response.

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*