Stability AI SDXL Image Generation using Replicate - n8n Workflow

Use this comprehensive n8n workflow to generate high-quality images from text prompts using Stability AI SDXL via the Replicate API. Features status tracking and robust error handling.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

A Markdown-formatted list of user personas:

AI Developers and Researchers needing programmatic access to SDXL.
Marketing teams requiring on-demand, custom image assets.
Users looking for advanced, production-ready n8n templates for AI tasks.
Automation Specialists building complex, multi-step n8n workflows that integrate external APIs.


  • Content creators who want to automate image creation using a powerful n8n node setup.

Overview

Generating high-quality images using state-of-the-art models like Stability AI's SDXL often requires complex polling logic since generation is asynchronous. This specialized n8n workflow solves that challenge by providing a complete, ready-to-run automation pipeline. It handles the initial request submission to the Replicate API, implements logging, and establishes an intelligent status checking loop that waits until the image is either successfully generated or fails. This robust design makes this n8n workflow ideal for production environments, offering error resilience and structured results. This specific n8n templates configuration uses various n8n node types to ensure reliable execution.

How it Works

This automation starts with the Manual Trigger n8n node, allowing for easy testing and initialization.


  1. Setup and Configuration: The workflow first runs through two Set n8n nodes: 'Set API Token' (where you configure your Replicate key) and 'Set Image Parameters' (where you define the prompt, dimensions, and other SDXL settings).

  2. Request Submission: The 'Create Image Prediction' HTTP Request n8n node submits the generation request to the Replicate API, receiving an immediate prediction ID.

  3. Logging: The 'Log Request' Code n8n node records essential metadata for monitoring the n8n workflow execution.

  4. Initial Wait: The 'Wait 5s' n8n node pauses the flow, allowing the model time to start processing.

  5. Polling Loop: The 'Check Status' HTTP Request n8n node repeatedly queries the Replicate endpoint using the prediction ID to fetch the current status.

  6. Conditional Routing: The 'Is Complete?' If n8n node checks if the status is 'succeeded'. If not, 'Has Failed?' checks for failure.

  7. Retry Logic: If the status is still 'processing', the n8n workflow routes execution to the 'Wait 10s' n8n node, and then loops back to 'Check Status', ensuring continuous monitoring until completion.

  8. Final Output: Upon successful generation, the 'Success Response' n8n node packages the resulting image URL. If it fails, the 'Error Response' n8n node captures the error details. The final 'Display Result' n8n node presents the structured output.

Installation Guide

To utilize this powerful n8n workflow, follow these steps:


  1. Import the n8n Templates: Copy the provided JSON code and import it directly into your n8n instance via the Workflows section (New -> Import from JSON).

  2. Set Replicate Credentials: Obtain an API token from Replicate (https://replicate.com/).

  3. Configure API Token n8n Node: Locate the 'Set API Token' n8n node. Replace the placeholder value YOURREPLICATEAPI_TOKEN with your actual Replicate API token.

  4. Customize Parameters: Navigate to the 'Set Image Parameters' n8n node to adjust the prompt, width, height, and other Stability AI SDXL specific inputs.

  5. Activate: Click the 'Manual Trigger' n8n trigger to test the n8n workflow execution, or activate the workflow to use it via a webhook or scheduled n8n trigger.

Node Details

This n8n workflow utilizes several key n8n node types:

Manual Trigger (n8n trigger): The starting point for execution. Used here to manually initiate the SDXL image generation process.
Set API Token (Set n8n node): Essential configuration step. Stores the required api_token for Replicate, making it securely accessible to subsequent HTTP Request n8n node calls.
Set Image Parameters (Set n8n node): Holds the specific inputs for the SDXL model, such as prompt (default: 'An astronaut riding a rainbow unicorn'), width (1024), height (1024), and various refinement parameters.
Create Image Prediction (HTTP Request n8n node): Sends a POST request to https://api.replicate.com/v1/predictions. Key configuration includes setting the model version ID and authenticating using the Bearer token defined earlier. It also utilizes the Prefer: wait header.
Wait 5s / Wait 10s (Wait n8n node): Controls the polling frequency, ensuring the n8n workflow does not overload the API while waiting for a potentially long-running generation task to complete.
Check Status (HTTP Request n8n node): Periodically fetches the status using the prediction ID provided by the initial request. This demonstrates robust integration logic in the n8n workflow.
Is Complete? / Has Failed? (If n8n node): Implements flow control logic, checking the returned status field. This decision n8n node dictates whether the workflow proceeds to success, error logging, or another wait cycle.
Success Response / Error Response (Set n8n node): Structures the final output data. The success branch returns the image URL ($json.output), while the error branch returns the status and detailed error message.

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*