JSON Format for Edits: Calling the Dall E 2 API from VBA

Hi everyone.
I’ve been working on VBA code to help me improve my personal workflow within PowerPoint using the OpenAI API. Since I couldn’t find many VBA examples of using the OpenAI API, I’ve been building the JSON strings manually (like an animal). So far it has worked swimmingly and I have a few use cases already up and running. Now I wanted to get to the part about the edits. I want to share an image for edits, and I’m using the below code, but it doesn’t work. I’ll share both the outgoing JSON and the response I get.

{
	"model":"dall-e-2",
	"image":"image/png;base64,[base64 data here]",
	"mask":"image/png;base64,[base64 data here]",
	"prompt":"[prompt text here]",
	"n":1,
	"size":"1024x1024"
}

Response:

{
  "error": {
    "code": null,
    "message": "'image' is a required property",
    "param": null,
    "type": "invalid_request_error"
  }
}

I’m using POST with the endpoint “/v1/ images / edits”, and “Content-Type” as “multipart/form-data”. Earlier when I was using Content-Type application/json, it gave me an error saying that it expected multipart/form-data…

Can one of you guys please help me put this thing together? Highly appreciated!

Guys, would appreciate any support - I’m a non developer nerd who’s looking to make something interesting :slight_smile: