Keep getting "'image' is a required property" when using valid image urls?

Hi, why do I keep getting 400 errors despite having valid image URLs converted into buffers?

const response = await axios.get(input,  { responseType: 'arraybuffer' })
  const buffer = Buffer.from(response.data, "utf-8")
  buffer.name = "image.png";
  var data = JSON.stringify({
  "image": input,
  "n": 10,
  "size": "1024x1024"
});

var config = {
  method: 'post',
  url: 'https://api.openai.com/v1/images/variations',
  headers: { 
    'Authorization': 'Bearer ' + apikey, 
    'Content-Type': 'multipart/form-data'
  },
  data : data
};

await axios(config)
.then(function (response) {
      let toInsert = {
  "key":        key,
  "output":   response.data.data[0].url,
  "output2":   response.data.data[1].url,
  "output3":   response.data.data[2].url,
  "output4":   response.data.data[3].url,
  "output5":   response.data.data[4].url,
  "output6":   response.data.data[5].url,
  "output7":   response.data.data[6].url,
  "output8":   response.data.data[7].url,
  "output9":   response.data.data[8].url,
  "output10":   response.data.data[9].url,
  "title":    "response"
}

I’ve tried passing plain image URLs, Data Urls, and buffers. Why does it keep telling me “Image property is required” despite having a valid image?

2 Likes

Hey @sewellstephens104, did you find a solution?

I’m getting same error using images edit API with PHP.
My payload is this:

$params = [
            'image' => fopen($filePath, 'r'),
            'prompt' => $prompt,
          ];