OpenAI DALL-E Image Editing via Custom HTTP Request - n8n Workflow

Automate OpenAI DALL-E image editing using a custom n8n workflow. Trigger edits with a prompt and source image, then convert the Base64 output back to a file using an n8n node.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Automation developers seeking custom API integration solutions within n8n.

  • Users running AI services or image processing pipelines.

  • Technical content creators leveraging the power of an n8n node for advanced binary data handling.

  • Anyone utilizing n8n templates for generative AI workflows.

Overview

This specialized n8n workflow addresses the challenge of integrating complex, multi-part form data API calls, specifically for the OpenAI Image Generation 1 Edits endpoint. By utilizing the flexible HTTP Request n8n node, this n8n template demonstrates how to successfully upload a source image, pass a text prompt, and handle the resulting Base64 file output from the AI service. This n8n automation is crucial for developers looking to build scalable image editing tools or SaaS products where user interaction (via the When chat message received n8n trigger) dictates the image transformation. The output of this robust n8n workflow is a ready-to-use image file.

How it Works

The n8n workflow initiates using the specialized When chat message received n8n trigger. This powerful n8n trigger captures both the source image (uploaded as binary data) and the user's text instruction (the prompt).


  1. Key Injection: The API KEY n8n node immediately follows, securely setting the user's OpenAI secret key into the data stream, preparing it for authentication.

  2. API Call: The HTTP Request n8n node executes a POST call to the OpenAI Edits API (/v1/images/edits). This n8n node is configured specifically for multipart-form-data, ensuring that the uploaded image binary data (data0) and the dynamic prompt ({{ $...chatInput }}) are correctly packaged and sent, along with necessary headers containing the bearer token.

  3. Result Conversion: The OpenAI API returns the edited image encoded as Base64 within a JSON structure. The final step involves the Convert to File n8n node. This essential n8n node decodes the Base64 string property (data[0].b64_json) back into a standard binary file, completing the n8n workflow and making the edited image accessible for subsequent actions.

Installation Guide

To deploy this n8n workflow template:


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

  2. API Key Setup: Locate the API KEY n8n node. Edit the placeholder value (sk-proj-...) to include your actual OpenAI secret API key. Note that while this n8n node uses a Set function, for production n8n workflows, it is best practice to use an n8n credential.

  3. Trigger Setup: Ensure the When chat message received n8n trigger is active. You may need to expose the webhook URL associated with this n8n trigger if integrating with an external chat interface.

  4. Activation: Save the n8n workflow and click 'Activate' to start the automation. This n8n template is now ready to process image editing requests.

Node Details

When chat message received (n8n trigger)
Function: Acts as the starting n8n trigger for the automation, capturing the text prompt and allowing file uploads (the source image) which are then passed to the next n8n node.
Key Configuration: allowFileUploads: true ensures the source image is captured.

API KEY (Set n8n node)
Function: Inserts the OpenAI API key into the workflow data structure (openAIKey) for authorization in the subsequent HTTP Request n8n node.
Key Configuration: Sets the openAIKey variable.

HTTP Request (n8n node)
Function: Performs the core task: sending the image and prompt to the OpenAI Image Edits API via a POST request.
Key Configuration: URL: https://api.openai.com/v1/images/edits. contentType: multipart-form-data. Sends binary data from the trigger (data0) as the image parameter and the chat input as the prompt parameter.

Convert to File (n8n node)
Function: Transforms the Base64 encoded image data received in the API response into a usable binary file within the n8n context.
Key Configuration: operation: toBinary. sourceProperty: data[0].b64_json (the location of the Base64 string in the OpenAI response).

Related n8n Workflows

Free

Nodes: 5 Nodes
Updated: December 26 2025
View all
Created by
TechDennis
TechDennis

Featured*