OpenAI CLIP Prediction Polling Automation via Replicate API - n8n Workflow

Use this advanced n8n workflow template to reliably handle asynchronous AI prediction tasks (like OpenAI CLIP) via Replicate, featuring efficient API polling logic.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Developers requiring reliable integration with asynchronous AI APIs like Replicate.

  • Users looking for advanced n8n templates demonstrating robust API polling and flow control.

  • Automation specialists needing to execute long-running tasks within an n8n workflow.

  • Anyone utilizing OpenAI CLIP for embedding or classification tasks.

Overview

This expert n8n workflow demonstrates a critical pattern for interacting with third-party APIs that handle long-running, asynchronous tasks, such as complex AI predictions. Specifically, this n8n automation utilizes the Replicate API to access the powerful OpenAI CLIP model. Since these tasks take time, a standard synchronous HTTP request would fail. This robust n8n node structure solves this by submitting the request, extracting the unique prediction ID, and then entering a core logic flow control loop. This loop, utilizing the 'Wait' n8n node and an 'If' n8n node, continuously polls Replicate until the prediction status is reported as succeeded, ensuring the complete result is captured within your n8n workflow. This is a vital n8n template for any user working with large or complex AI models.

How it Works

The process begins with the 'On clicking 'execute'' n8n trigger.


  1. API Key Setup: The 'Set API Key' n8n node securely stores the Replicate API key.

  2. Create Prediction: An 'HTTP Request' n8n node submits a POST request to Replicate's API, initiating the prediction job for the openai/clip model version.

  3. Extract ID: The 'Extract Prediction ID' n8n node processes the initial response, grabbing the unique prediction ID and creating the necessary polling URL. This is critical for the subsequent polling loop.

  4. Polling Loop Initiation: The n8n workflow enters a loop starting with the 'Wait' n8n node, pausing execution for 2 seconds to prevent rate-limiting.

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

  6. Flow Control: The 'Check If Complete' n8n node (an If node) evaluates the status. If the status is equal to succeeded, the n8n workflow exits the loop and proceeds to 'Process Result'. If the status is anything else (e.g., starting, processing), the n8n node routes the execution back to the 'Wait' node, restarting the polling cycle. This robust logic ensures the n8n workflow does not complete until the AI result is ready.

  7. Final Processing: The 'Process Result' n8n node cleans and formats the successful output, making the generated CLIP data easily accessible.

Installation Guide

To use this n8n workflow template, follow these steps:


  1. Import: Copy the JSON code and paste it directly into your n8n canvas using the 'New' > 'Import workflow from JSON' option.

  2. API Key Configuration: Locate the 'Set API Key' n8n node. Replace the placeholder value YOURREPLICATEAPI_KEY with your actual Replicate API key. This key is securely used in the HTTP Header Authorization of the subsequent n8n nodes.

  3. Run: Since this n8n workflow uses a 'Manual Trigger' n8n trigger, click the 'Execute Workflow' button in the top right corner to run a test.

  4. Customization: Modify the JSON body within the 'Create Prediction' n8n node to specify the exact input parameters required by the openai/clip model if you need specific text prompts or image URLs for embedding.

Node Details


  • On clicking 'execute' (Manual Trigger): Serves as the starting n8n trigger for the entire n8n workflow. Used for easy testing and manual runs.

  • Set API Key (Set n8n node): Stores the Replicate API key under the variable replicateapikey. This data is dynamically referenced by other n8n nodes for authentication.

  • Create Prediction (HTTP Request n8n node): Initiates the asynchronous job with Replicate. Uses Generic Credential Type and constructs the Authorization: Bearer header using the stored replicateapikey.

  • Extract Prediction ID (Code n8n node): Essential custom n8n node logic. Extracts the unique id returned from the API and prepares the necessary predictionUrl for the subsequent polling requests.

  • Wait (Wait n8n node): Implements a 2-second delay within the polling loop. This is critical for efficient n8n workflow execution and to avoid overwhelming the external API.

  • Check Prediction Status (HTTP Request n8n node): Polls the Replicate status URL (derived from the predictionUrl) until the job is complete.

  • Check If Complete (If n8n node): The core flow control n8n node. Compares the returned status to succeeded. If false, it loops back to the 'Wait' n8n node, continuing the asynchronous polling sequence.

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*