Image edits gets error 415

In my react native expo app I’m trying to use image edits but I keep getting this error and don’t know what I could be doing wrong.

I saw in some tutorials that having a blank square is enough, so I’m passing an image and the image as image with the blank square as mask. This is the mask:
Captura de pantalla 2023-10-07 a la(s) 15.21.51

Before sending the to the API I make sure to covert it to PNG and make it smaller than 4MB.
But after doing that I’ve tried to pass the base64 encoded image as a string and as a buffer but I keep getting the error 415. I also tried sending only the image with the square and no mask but got the same result, so I’m not sure what else I should try.

Hopefully somebody has some ideas.
variables imageData and maskData have the base64 encoded image:

const generateEditedImage = async () => {
        const imageBuffer = Buffer.from(imageData, "base64");
        const maskBuffer = Buffer.from(maskedData, "base64");
        // Define the parameters for the OpenAI API request
        const params = {
            image: imageBuffer, 
            mask: maskBuffer,
            prompt: 'A cute bug',
            n: 1,
        // Make an API request to OpenAI to generate the edited image
        try {
          const response = await fetch('', {
            method: 'POST',
            headers: {
              'Content-Type': 'application/json',
              Authorization: `Bearer ${apiKey}`,
            body: JSON.stringify(params),
          if (response.ok) {
            const result = await response.json();
            console.log('RESULT 😃: ', result)
            // Set the edited image as the maskedImage
          } else {
            console.error('Error generating image:', response);
        } catch (error) {
          console.error('Error generating the image:', error);
        } finally {

This is what I get:

Error generating image: {“_bodyBlob”: {“_data”: {“__collector”: [Object], “blobId”: “391173D3-3F95-4A4A-8171-19893D471014”, “name”: “edits.json”, “offset”: 0, “size”: 272, “type”: “application/json”}}, “_bodyInit”: {“_data”: {“__collector”: [Object], “blobId”: “391173D3-3F95-4A4A-8171-19893D471014”, “name”: “edits.json”, “offset”: 0, “size”: 272, “type”: “application/json”}}, “bodyUsed”: false, “headers”: {“map”: {“access-control-allow-origin”: “*”, “alt-svc”: “h3=":443"; ma=86400”, “cf-cache-status”: “DYNAMIC”, “cf-ray”: “812841817aeb0dd4-SCL”, “content-length”: “272”, “content-type”: “application/json”, “date”: “Sat, 07 Oct 2023 18:37:34 GMT”, “openai-organization”: “user-nj5vw83cmfithrtdnirgcpn6”, “openai-processing-ms”: “85”, “openai-version”: “2020-10-01”, “server”: “cloudflare”, “strict-transport-security”: “max-age=15724800; includeSubDomains”, “x-request-id”: “6a640bccdae1a729f9a3206111eb4d4d”}}, “ok”: false, “status”: 415, “statusText”: “”, “type”: “default”, “url”: “”}