⚒️ Process multiple prompts in parallel with Azure OpenAI Batch API

727 views · ⚒️ Engineering

💡 Pro Tip — HTTP Request scraping tends to break when sites update their markup. If you’re scraping a major platform, check if ScraperNode covers it — it has maintained scrapers for LinkedIn, Instagram, TikTok, YouTube, and 20+ other platforms that return structured data.

View All Scrapers

Description

Process Multiple Prompts in Parallel with Azure OpenAI Batch API

Who is this for?

This workflow is designed for developers and data scientists who want to efficiently send multiple prompts to the Azure OpenAI Batch API and retrieve responses in a single batch process. It is particularly useful for applications that require processing large volumes of text data, such as chatbots, content generation, or data analysis.

What problem is this workflow solving?

Sending multiple prompts to the Azure OpenAI API can be time-consuming and inefficient if done sequentially. This workflow automates the process of batching requests, allowing users to submit multiple prompts at once and retrieve the results in a streamlined manner. This not only saves time but also optimizes resource usage.

What this workflow does

This workflow:

  1. Accepts an array of requests, each containing a prompt and associated parameters.
  2. Converts the requests into a JSONL format suitable for batch processing.
  3. Uploads the batch file to the Azure OpenAI API.
  4. Creates a batch job to process the prompts.
  5. Polls for the job status and retrieves the output once processing is complete.
  6. Parses the output and returns the results.

Key Features of Azure OpenAI Batch API

The Azure OpenAI Batch API is designed to handle large-scale and high-volume processing tasks efficiently. Key features include:

Key Use Cases

Setup

  1. Azure OpenAI Credentials: Ensure you have your Azure OpenAI API credentials set up in n8n.
  2. Configure the Workflow:
    • Set the az_openai_endpoint in the “Setup defaults” node to your Azure OpenAI endpoint.
    • Adjust the api-version in the “Set desired ‘api-version’” node if necessary.
  3. Run the Workflow: Trigger the workflow using the “Run example” node to see it in action.

How to customize this workflow to your needs

Example Input

[
  {
    "api-version": "2025-03-01-preview",
    "requests": [
      {
        "custom_id": "first-prompt-in-my-batch",
        "params": {
          "messages": [
            {
              "content": "Hey ChatGPT, tell me a short fun fact about cats!",
              "role": "user"
            }
          ]
        }
      },
      {
        "custom_id": "second-prompt-in-my-batch",
        "params": {
          "messages": [
            {
              "content": "Hey ChatGPT, tell me a short fun fact about bees!",
              "role": "user"
            }
          ]
        }
      }
    ]
  }
]

Example Output

[
  {
    "custom_id": "first-prompt-in-my-batch",
    "response": {
      "body": {
        "choices": [
          {
            "message": {
              "content": "Did you know that cats can make over 100 different sounds?"
            }
          }
        ]
      }
    }
  },
  {
    "custom_id": "second-prompt-in-my-batch",
    "response": {
      "body": {
        "choices": [
          {
            "message": {
              "content": "Bees communicate through a unique dance called the 'waggle dance'."
            }
          }
        ]
      }
    }
  }
]

Additional Notes

This template provides a comprehensive solution for efficiently processing multiple prompts using the Azure OpenAI Batch API, making it a valuable tool for developers and data scientists alike.

🔗 Nodes Used

HTTP Request, Execute Sub-workflow, Execute Workflow Trigger, Filter, Execution Data, Simple Memory

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup