Skip to content

The most powerful and modular diffusion model GUI, api and backend with a graph/nodes interface. The fastest local inference engine in the world.

fix(OpenAIGPTImage1): set correct MIME type for multipart uploads to OpenAI edits (#9348)

Alexander Piskun027c63f63a7f
diff --git a/comfy_api_nodes/nodes_openai.py b/comfy_api_nodes/nodes_openai.py
index ab3c5363b..cbff2b2d2 100644
--- a/comfy_api_nodes/nodes_openai.py
+++ b/comfy_api_nodes/nodes_openai.py
@@ -464,8 +464,6 @@ class OpenAIGPTImage1(ComfyNodeABC):
path = "/proxy/openai/images/generations"
content_type = "application/json"
request_class = OpenAIImageGenerationRequest
- img_binaries = []
- mask_binary = None
files = []
if image is not None:
@@ -484,14 +482,11 @@ class OpenAIGPTImage1(ComfyNodeABC):
img_byte_arr = io.BytesIO()
img.save(img_byte_arr, format="PNG")
img_byte_arr.seek(0)
- img_binary = img_byte_arr
- img_binary.name = f"image_{i}.png"
- img_binaries.append(img_binary)
if batch_size == 1:
- files.append(("image", img_binary))
+ files.append(("image", (f"image_{i}.png", img_byte_arr, "image/png")))
else:
- files.append(("image[]", img_binary))
+ files.append(("image[]", (f"image_{i}.png", img_byte_arr, "image/png")))
if mask is not None:
if image is None:
@@ -511,9 +506,7 @@ class OpenAIGPTImage1(ComfyNodeABC):
mask_img_byte_arr = io.BytesIO()
mask_img.save(mask_img_byte_arr, format="PNG")
mask_img_byte_arr.seek(0)
- mask_binary = mask_img_byte_arr
- mask_binary.name = "mask.png"
- files.append(("mask", mask_binary))
+ files.append(("mask", ("mask.png", mask_img_byte_arr, "image/png")))
# Build the operation
operation = SynchronousOperation(