Server error when trying to use vision to analyze image using chat completion

I’m trying to run a chat completion to analyze an image. 3 days ago it didn’t work. I was getting a 500 code error. Yesterday I ran the same code and it worked. Today it doesn’t and I get a similar 500 error.

The code is the one copy pasted from docs, just changed the image link

response = client.chat.completions.create(
  model="gpt-4o-mini",
  messages=[
    {
      "role": "user",
      "content": [
        {"type": "text", "text": "What’s in this image?"},
        {
          "type": "image_url",
          "image_url": {
            "url": "https://letsenhance.io/static/8f5e523ee6b2479e26ecc91b9c25261e/1015f/MainAfter.jpg",
          },
        },
      ],
    }
  ],
  max_tokens=300,
)

Any ideas?

Welcome to our community!

I tried calling the API using the same code, and it worked fine.

A 500 error usually indicates an internal server error, but it can also occur if the proxy server is overloaded.

If you are using one, why not try accessing it without going through a proxy server or VPN?

1 Like

Yep. I was indeed on a VPN without realizing. But still, it doesn’t work, I disconnected from the VPN, and restarted my PC and I still got the 500 error…

1 Like

Update: I run it from VScode and I receive 500 code. I run it just from cmd and it works fine. Idk what to say

1 Like

Hi @ionbelei549 !

Just out of curiosity - what if you pass the image as a base64 encoded string like in this example, as opposed to supplying the uri?

Just wondering if something is happening with url fetch on the server end (shouldn’t be a problem, but just to rule that out).

1 Like

It works using this method, thank you!

1 Like