# Cannot send image\_url to gpt-4o

**URL:** <https://community.openai.com/t/cannot-send-image-url-to-gpt-4o/763827>\
**Category:** API\
**Created:** [May 19, 2024, 1:09am UTC](https://community.openai.com/t/cannot-send-image-url-to-gpt-4o/763827 "2024-05-19T01:09:40Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kevrab](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/kevrab/32/146784_2.png) [@kevrab](https://community.openai.com/u/kevrab)\
**Post date:** [May 19, 2024, 1:09am UTC](https://community.openai.com/t/cannot-send-image-url-to-gpt-4o/763827/1 "2024-05-19T01:09:40Z")

</div>

I’m trying to send image\_url under ‘user’ role to gpt-4o. However every time I send it, it complains with that the model does not support image\_url:

```auto
Invalid content type. image_url is only supported by certain models.

```

I’ve tried other models like gpt-4-turbo, but every time it gets rejected. I’m on Tier 1 usage currently which appears to allow me to use these models, but is there something else I’m missing? Or is this a bug?

---

<div class="post-metadata">

**Author:** ![nick.youngblut](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/nick.youngblut/32/148289_2.png) [@nick.youngblut](https://community.openai.com/u/nick.youngblut)\
**Post date:** [May 27, 2024, 7:33pm UTC](https://community.openai.com/t/cannot-send-image-url-to-gpt-4o/763827/2 "2024-05-27T19:33:28Z")

</div>

I’m getting the same (`openai 1.30.3`).

My message content:

```auto
{'type': 'image_url', f'data:image/png;base64,{base64_image}'}

```

I’m using base64 png images pulled from a Jupyter notebook.

My chat completions code:

```auto
stream = client.chat.completions.create(
    model="gpt-4o",
    messages=my_messages,
    stream=True
)

for chunk in stream:
    if chunk.choices[0].delta.content is not None:
        print(chunk.choices[0].delta.content, end="")

```

The response:

```auto
BadRequestError: Error code: 400 - {'error': {'message': 'Invalid content type. image_url is only supported by certain models.', 'type': 'invalid_request_error', 'param': 'messages.[1].content.[1].type', 'code': None}}

```

---

<div class="post-metadata">

**Author:** ![iiitmahesh](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/iiitmahesh/32/298284_2.png) [@iiitmahesh](https://community.openai.com/u/iiitmahesh)\
**Post date:** [May 27, 2024, 8:01pm UTC](https://community.openai.com/t/cannot-send-image-url-to-gpt-4o/763827/3 "2024-05-27T20:01:20Z")

</div>

is there way to upload files like gpt-4o ui through API?

---

<div class="post-metadata">

**Author:** ![sashirestela](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/sashirestela/32/191115_2.png) [@sashirestela](https://community.openai.com/u/sashirestela)\
**Post date:** [May 27, 2024, 8:18pm UTC](https://community.openai.com/t/cannot-send-image-url-to-gpt-4o/763827/4 "2024-05-27T20:18:45Z")

</div>

That functionality is working by my side.

First I’m creating both an Assistant (with gpt-4o) and a Thread (empty).

Next, I’m hitting this endpoint:

POST [https://api.openai.com/v1/threads/{threadId}/messages](https://api.openai.com/v1/threads/%7BthreadId%7D/messages)  
Body:

```auto
{
  "role": "user",
  "content": [
    {
      "type": "text",
      "text": "Do you see any similarity or difference between the attached images?"
    },
    {
      "type": "image_file",
      "image_file": {
        "file_id": "file-Vl3rOrhupx0MFHwsVjvjva4S",
        "detail": "low"
      }
    },
    {
      "type": "image_url",
      "image_url": {
        "url": "https://upload.wikimedia.org/wikipedia/commons/e/eb/Machu_Picchu%2C_Peru.jpg",
        "detail": "low"
      }
    }
  ]
}

```

Then, I’m hitting this other endpoint:

POST: [https://api.openai.com/v1/threads/{threadId}/runs](https://api.openai.com/v1/threads/%7BthreadId%7D/runs)  
Body:

```auto
{
  "assistant_id": "asst_kfoHDe4qk8JwqOwtM9PdROJN",
  "stream": true
}

```

And I’m receiving this response in chunks of text:

```txt
Both images appear to be identical, depicting the iconic site of Machu Picchu in Peru. Machu Picchu is a 15th-century Inca citadel located in the Eastern Cordillera of southern Peru. It is set on a mountain ridge and is situated approximately 2,430 meters (7,970 feet) above sea level.

Similarities:
1. Both images show the same panoramic view of the Machu Picchu archaeological site.
2. The notable features such as the terraces, stone structures, and the prominent Huayna Picchu mountain in the background are visible in both images.

Since the images are the same, there are no differences to point out. This preserved Incan site demonstrates remarkable engineering and architectural skills, and it's a significant cultural heritage of the Inca civilization.

```

Just in case, I’m using the [simple-openai](https://github.com/sashirestela/simple-openai) library.

---

<div class="post-metadata">

**Author:** ![nick.youngblut](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/nick.youngblut/32/148289_2.png) [@nick.youngblut](https://community.openai.com/u/nick.youngblut)\
**Post date:** [October 2, 2024, 9:47pm UTC](https://community.openai.com/t/cannot-send-image-url-to-gpt-4o/763827/5 "2024-10-02T21:47:06Z")

</div>

The error message is misleading. It should state that the API body is malformed:

```auto
{'type': 'image_url', f'data:image/png;base64,{base64_image}'}

```

Should be:

```auto

{'type': 'image_url', 
 'image_url' : {
    'url' : f'data:image/png;base64,{base64_image}'
}}

```
