OpenAI DALL-E Image Generation via HTTP Request - n8n Workflow

Use this powerful n8n workflow template to generate custom images via the OpenAI DALL-E API (GPT-Image-1). Learn how to set variables, handle API calls using an n8n node, and convert Base64 output into usable binary files.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Content teams needing bulk creation of unique images. Developers looking to integrate the latest OpenAI API features before official n8n node support exists. Users seeking advanced examples of using the HTTP Request n8n node for custom API calls. Anyone interested in creating powerful custom n8n templates for generative AI.

Overview

This n8n workflow provides a robust solution for accessing OpenAI’s cutting-edge image generation models, like DALL-E 3 (referenced as gpt-image-1 in the prompt variables). While many automations use pre-built nodes, this example teaches you how to leverage the HTTP Request n8n node to communicate directly with external APIs, which is vital for integrating brand new services or complex custom headers. The most crucial part of this n8n template is the process of retrieving the image data, which arrives as a Base64 encoded JSON string, and converting it into a standard binary file using the specialized Convert to File n8n node. This approach ensures maximum flexibility and immediate adoption of new AI features within your n8n automation environment.

How it Works

The logical flow of this n8n workflow template is highly structured, ensuring reliable image generation and file conversion.


  1. n8n Trigger: The workflow starts with the 'When clicking ‘Test workflow’' n8n trigger, allowing for immediate testing and easy adaptation to other n8n trigger types (e.g., Webhook, Schedule).

  2. Define Inputs: The 'Set Variables' n8n node defines all necessary parameters for the image generation call: the imageprompt, numberofimages, desired qualityofimage (set to 'high'), sizeofimage (set to '1024x1024'), and the specific openaiimagemodel (gpt-image-1).

  3. Call OpenAI API: The 'OpenAI - Generate Image' HTTP Request n8n node uses a predefined OpenAI credential to authenticate the POST request. It dynamically constructs the JSON payload using the variables set in the previous step, sending the request to the /v1/images/generations endpoint.

  4. Separate Results: The API can return multiple images. The 'Separate Image Outputs' n8n node uses the Split Out function to ensure that each generated image is passed down the workflow pipeline as an individual item, allowing for per-image processing.

  5. Convert Data Type: The final essential step involves the 'Convert to File' n8n node. Since OpenAI returns image data embedded within a b64json field, this n8n node converts that Base64 encoded string into a binary data object. The resulting binary file is now ready to be saved to cloud storage (e.g., AWS S3, Google Drive) or local disk using a subsequent n8n node.

Installation Guide

To deploy this powerful n8n workflow, follow these steps:


  1. Import: Copy the provided JSON data and paste it directly into your n8n instance using the 'New' menu and 'Import from JSON' option.

  2. OpenAI Credential Setup: This n8n workflow relies on an 'OpenAiApi' credential. You must configure this credential with your OpenAI API Key (starting with sk-). If you already have one set up, ensure the HTTP Request n8n node ('OpenAI - Generate Image') is linked correctly.

  3. Customize Variables: Review the 'Set Variables' n8n node and update the image_prompt and other quality/size parameters to match your specific generation requirements.

  4. Test: Click the 'Test workflow' n8n trigger node to execute the flow and observe the generated binary file output in the 'Convert to File' n8n node.

Node Details

When clicking ‘Test workflow’ (manualTrigger): Acts as the starting n8n trigger for testing the automation structure.
Set Variables (Set n8n node): Defines the core input parameters for the OpenAI API call, including the image prompt and specific model (gpt-image-1) and quality settings (e.g., 'high').
OpenAI - Generate Image (HTTP Request n8n node): This is the core communication n8n node. It is configured to send a POST request to the OpenAI image generation API endpoint, securely authenticated using an OpenAiApi credential, passing the dynamic input variables as a JSON body.
Separate Image Outputs (Split Out n8n node): Ensures parallel processing of multiple generated images by splitting the incoming data array (data field) into separate execution items, a crucial step for handling bulk generation within the n8n workflow.


  • Convert to File (Convert to File n8n node): Performs the necessary data transformation. It specifically targets the b64_json property from the OpenAI response and converts the Base64 string into a binary file format, making the image usable by file manipulation nodes further down the n8n workflow.

Related n8n Workflows

Free

Nodes: 6 Nodes
Updated: December 26 2025
View all
Created by

Max is an IBM-certified AI developer with a BS in Computer Science and 20+ years in software, AI consulting, and leadership. He founded several modest ventures and serves as Board President of RedeemTheOppressed.org. Married with five children, he’s raised over $3.5M for persecuted minorities. Ventures: Motivate-Mate.com | | MusicWithMax.com | VoiceAIBonanza.com | ApexWebServices.com | HeimishGiving.org | ForAfricanJews.org | AI Automation community - https://community.stan.store/apexwebservices

Featured*