Custom AI Avatar Generation via Replicate API Polling - n8n Workflow

Automate custom AI avatar generation using the babysea/babyavatar model on Replicate. This robust n8n workflow handles setup, asynchronous API calls, and status polling efficiently.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Marketing professionals and content creators needing custom image assets quickly.
n8n automation specialists looking for advanced API polling examples.


  • Developers building AI-powered applications who need reliable serverless generation.

Overview

This comprehensive n8n workflow template provides a reliable structure for interacting with asynchronous AI models like babysea/babyavatar on the Replicate platform. The challenge with many AI models is that image generation takes time, requiring a robust polling mechanism. This n8n workflow addresses this by automating the entire process: setting the parameters, initiating the prediction request via a specialized n8n node, and continuously checking the status until the image generation succeeds or fails. Using this pre-built n8n template saves significant development time and ensures a production-ready solution for automated avatar creation, leveraging the power of Replicate and seamless integration with n8n.

How it Works

The process begins with the Manual Trigger, which is the starting n8n trigger for the execution. First, the workflow securely sets the Replicate API token and then configures all necessary generation parameters (such as prompt, image URL, width, and height) in the subsequent n8n node, 'Set Other Parameters'. Next, the 'Create Other Prediction' HTTP Request n8n node sends a POST request to Replicate to start the AI generation process, returning a prediction ID. The workflow then enters a robust status polling loop. It initially waits for 5 seconds ('Wait 5s'), then checks the generation status using the prediction ID via the 'Check Status' n8n node. The 'Is Complete?' n8n node determines if the status is 'succeeded'. If successful, it branches to 'Success Response'. If it's not complete, it checks if it 'Has Failed?'. If the generation is still running (neither succeeded nor failed), the n8n workflow waits for 10 seconds ('Wait 10s') and then loops back to 'Check Status', ensuring the automation can handle long-running generations. Finally, the outcome is recorded using either the 'Success Response' or 'Error Response' n8n node, providing a clean, structured output item via the 'Display Result' node. This efficient use of the n8n workflow ensures reliable asynchronous API interaction.

Installation Guide

To set up this n8n workflow, follow these steps:


  1. Import the n8n Template: Copy the provided JSON code and import it directly into your n8n instance via the Workflows section.

  2. Obtain Replicate Credentials: Sign up or log in to Replicate and obtain your personal API token.

  3. Configure API Token: Locate the Set API Token n8n node.

* Replace the placeholder YOURREPLICATEAPI_TOKEN with your actual token. This is crucial for API authentication within the n8n workflow.

  1. Adjust Parameters: Access the Set Other Parameters n8n node. Customize the prompt, image (if using image-to-image), width, height, and other advanced settings specific to the babysea/babyavatar model to tailor the generated output.

  2. Activate and Test: Ensure the n8n workflow is active, and use the Manual Trigger to test the execution and verify that the API connection and polling loop function correctly.

Node Details

This n8n workflow uses several specialized n8n nodes to manage the asynchronous generation process:

Manual Trigger: Serves as the starting n8n trigger for manual initiation, perfect for testing and single-run executions.
Set API Token / Set Other Parameters (Set): These crucial Set n8n nodes manage workflow data. They inject the confidential Replicate API key and configure over 20 generation parameters (like prompt, seed, lorascale) required by the babysea/babyavatar model before the main API call.
Create Other Prediction (HTTP Request): The primary execution n8n node.
Function: Sends a POST request to Replicate's /v1/predictions endpoint to initiate the AI generation process.
Key Configuration: Uses the Authorization: Bearer {{ $json.apitoken }} header and includes a complex JSON body dynamically constructed from the set parameters. The Prefer: wait header optimizes initial response time.
Wait 5s / Wait 10s (Wait): These Wait n8n nodes implement necessary time delays for asynchronous polling, controlling the frequency of status checks.
Check Status (HTTP Request):
Function: Polls the Replicate API using the unique prediction ID received from the initial request.
Key Configuration: Uses a dynamic URL to query the specific prediction: =https://api.replicate.com/v1/predictions/{{ $('Create Other Prediction').item.json.id }}.
Is Complete? / Has Failed? (If): Conditional logic n8n nodes forming the core polling loop. They inspect the status field to determine if the n8n workflow should proceed to success, failure, or continue polling.


  • Success Response / Error Response (Set): Handles final output formatting, generating structured JSON containing the resulting image URL (result_url) upon success or detailed error messages upon failure.

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*