# Trying to pass a base64 encoded image with node

**URL:** <https://community.openai.com/t/trying-to-pass-a-base64-encoded-image-with-node/939864>\
**Category:** API\
**Tags:** gpt-4\
**Created:** [September 14, 2024, 6:46am UTC](https://community.openai.com/t/trying-to-pass-a-base64-encoded-image-with-node/939864 "2024-09-14T06:46:18Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![mathiasmm](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/mathiasmm/32/448555_2.png) [@mathiasmm](https://community.openai.com/u/mathiasmm)\
**Post date:** [September 14, 2024, 6:46am UTC](https://community.openai.com/t/trying-to-pass-a-base64-encoded-image-with-node/939864/1 "2024-09-14T06:46:18Z")

</div>

I’m trying to pass a base64 encoded image to gpt-4o, but gets an 400 Invalid base64 image\_url.

I use the following code:

```auto
    const openairesponse = await openai.chat.completions.create({
    model: "gpt-4o",
    messages: [
      { role: 'system', content: "Convert the image to text" },
      {
      "role": "user",
      "content": [
        {
        "type": "image_url",
        "image_url": {
          //The base64 encoded image
          "url": "data:image/jpeg;base64,"+base64Image
        }
        }
      ]
      }
    ],
    });

```

The base64Image is s string starting with ‘/9j/’ and should be valid.

Any idea what I’m doing wrong?

/Mathias

---

<div class="post-metadata">

**Author:** ![tanm1](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/tanm1/32/150634_2.png) [@tanm1](https://community.openai.com/u/tanm1)\
**Post date:** [October 3, 2024, 10:18am UTC](https://community.openai.com/t/trying-to-pass-a-base64-encoded-image-with-node/939864/2 "2024-10-03T10:18:48Z")

</div>

Facing the same error, let me know if you have found a workaround or solution

---

<div class="post-metadata">

**Author:** ![mathiasmm](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/mathiasmm/32/448555_2.png) [@mathiasmm](https://community.openai.com/u/mathiasmm)\
**Post date:** [October 3, 2024, 10:40am UTC](https://community.openai.com/t/trying-to-pass-a-base64-encoded-image-with-node/939864/3 "2024-10-03T10:40:16Z")

</div>

Unfortunately haven’t found a solution yet.
