# Unsupported image when uploading in memory file

**URL:** <https://community.openai.com/t/unsupported-image-when-uploading-in-memory-file/911664>\
**Category:** API\
**Tags:** api\
**Created:** [August 17, 2024, 11:16pm UTC](https://community.openai.com/t/unsupported-image-when-uploading-in-memory-file/911664 "2024-08-17T23:16:58Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![ExitareGP](https://avatars.discourse-cdn.com/v4/letter/e/43a26b/32.png) [@ExitareGP](https://community.openai.com/u/ExitareGP)\
**Post date:** [August 17, 2024, 11:16pm UTC](https://community.openai.com/t/unsupported-image-when-uploading-in-memory-file/911664/1 "2024-08-17T23:16:58Z")

</div>

Hi,  
I am uploading an image to my open ai storage.  
My upload code is this:

```auto
uploadedImage = await openai.files.create({ file: await toFile(filePart.data, filePart.filename, { type: filePart.type }), purpose: 'assistants' });

```

The upload works find and I am able to inspect the image via the web, being able to verify the correct name and suffix.

When I start a thread with messages referring to this image, the thread starts running and then abruptly ends with an error message.

```auto
 last_error: {
   code: 'invalid_image_format',
    message: "You uploaded an unsupported image. Please make sure your image is below 20 MB in size and is of one the following formats: ['png', 'jpeg', 'gif', 'webp']."
   },

```

If I change the upload to a fetch function to download a random image from my public storage, it works fine, as in, the newly uploaded image is being used by the thread, the thread is running and producing a response.  
With the same image uploaded through an in memory stream it doesnt work.  
The image is 4.3mb and I tried uploading jpeg and png, but both times it complains about a wrong format, which I cannot really understand why.

```auto
 openIAQueries.push({
        role: 'user',
        content: [
            {
                "type": "text",
                "text": "What's in this image?"
            },
            {
                "type": "image_file",
                "image_file": {
                    "file_id": uploadedImageId,
                }
            },
        ],
    });

 const thread = await openai.beta.threads.create({
            messages: openIAQueries,
        });

        let run = await openai.beta.threads.runs.create(
            thread.id,
            { assistant_id: assistant.id }
        );

        while (run.status === "queued" || run.status === "in_progress") {
            run = await openai.beta.threads.runs.retrieve(thread.id, run.id);
            console.log(`Run status: ${run.status}\n`);
        }

```

this is how I run my thread.

I am confused why everything is working when I use the fetch function, but not working when I upload the in memory image.

Thank you for any help
