AI Image Generation using Betia and Replicate API Polling - n8n Workflow

Use this powerful n8n workflow to automate text-to-image generation via the Replicate API (izzaanel/betia model). Features robust status checking and error handling.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Creative professionals needing automated batch image generation.
Developers integrating AI image generation into applications.
Technical users looking for advanced n8n templates utilizing polling logic.
Automation specialists seeking a production-ready Replicate integration within an n8n environment.

Overview

This production-ready n8n workflow provides a comprehensive solution for interacting with complex, asynchronous AI generation APIs like Replicate. The challenge with such APIs is that generation takes time, often requiring manual polling to retrieve the final result. This specific n8n workflow solves this by implementing an intelligent polling loop. It handles authentication, sets detailed generation parameters (prompt, dimensions, quality), initiates the prediction request, and then enters a loop using the Wait n8n node and If n8n node logic to constantly check the prediction status until it succeeds or fails. This complete automation guarantees reliability when running resource-intensive AI tasks, making it a valuable addition to your collection of n8n templates.

How it Works

The process begins with the Manual Trigger n8n trigger, initiating the generation sequence.


  1. Configuration: The workflow first uses the Set API Token n8n node to securely define the necessary Replicate API key, followed by the Set Other Parameters n8n node, which configures inputs like the prompt, width, height, and other model specifics for the Betia model.

  2. Prediction Request: The Create Other Prediction HTTP Request n8n node sends a POST request to the Replicate API to start the AI generation process, returning an immediate Prediction ID.

  3. Logging & Initial Wait: A Code n8n node (Log Request) records the request details, followed by a brief Wait 5s n8n node.

  4. Status Polling: The Check Status HTTP Request n8n node repeatedly queries the Replicate API using the Prediction ID to fetch the current status.

  5. Conditional Routing: The Is Complete? If n8n node determines the next step. If the status is 'succeeded', the flow moves to the Success Response n8n node.

  6. Retry Logic: If the status is not 'succeeded', the flow checks if it Has Failed?. If it hasn't failed (i.e., it's still processing), the workflow executes a Wait 10s n8n node and loops back to the Check Status n8n node to retry, creating a reliable polling mechanism.

  7. Final Output: Depending on the outcome, the data is routed to either the Success Response or Error Response n8n node, structuring the final result before displaying it in the Display Result n8n node.

Installation Guide

To deploy this powerful n8n workflow, follow these steps:


  1. Import the n8n template: Copy the provided JSON code and import it into your n8n instance using the 'New' button and selecting 'Import from JSON'.

  2. Obtain Replicate Credentials: Navigate to Replicate's website (https://replicate.com) and sign up or log in to obtain your API token.

  3. Configure API Token: Locate the Set API Token n8n node. Update the value field, replacing YOURREPLICATEAPI_TOKEN with your actual token.

  4. Adjust Parameters: Review the Set Other Parameters n8n node. Adjust the prompt, width, height, and other optional inputs to customize the AI generation according to your needs. This n8n node is crucial for setting up the image generation request.

  5. Activate and Test: Ensure the n8n workflow is active, and use the Manual Trigger n8n trigger to run a test execution. Monitor the execution steps to confirm successful completion and retrieval of the generated image URL.

Node Details

Manual Trigger (n8n trigger):
Function: Initiates the entire n8n workflow execution, typically used for testing or manually starting processes.
Key Configuration: None (Standard manual execution).
Set API Token (n8n node):
Function: Safely stores the Replicate API Bearer Token for use in subsequent HTTP requests.
Key Configuration: Sets a string assignment named apitoken to the placeholder value.
Set Other Parameters (n8n node):
Function: Defines all necessary input variables (prompt, dimensions, image links) for the izzaanel/betia model.
Key Configuration: Assigns over 20 parameters, including prompt (default: 'Create something amazing'), width (512), and height (512).
Create Other Prediction (HTTP Request n8n node):
Function: Sends the initial request to the Replicate API to start the asynchronous AI generation task.
Key Configuration: Method POST, URL https://api.replicate.com/v1/predictions. Uses expressions to inject all parameters into the JSON body and sets the Authorization header using the previously stored API token (Bearer {{ $json.api
token }}).
Wait 5s / Wait 10s (Wait n8n node):
Function: Used to introduce necessary delays in the polling loop, preventing excessive API calls and managing rate limits.
Key Configuration: Configured for 5 seconds and 10 seconds, respectively.
Check Status (HTTP Request n8n node):
Function: Repeatedly checks the status of the ongoing prediction using the ID returned from the creation step.
Key Configuration: Method GET, URL dynamically built using ={{ $json.id }}.
Is Complete? / Has Failed? (If n8n node):
Function: Core flow control logic. Checks the status field of the API response to route the flow based on whether the generation 'succeeded' or 'failed'.
Key Configuration: Conditions check if $json.status equals 'succeeded' or 'failed'.
Success Response / Error Response (Set n8n node):
Function: Structures the final output data (containing the result URL or error details) for easy consumption by the next steps in this n8n workflow.
Key Configuration: Creates a standardized JSON response object for successful (result_url) or failed (error) generations.

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*