Recurring "Invalid image" Error with GPT-4 Vision API Using Image URLs

Hello Community,

I’ve been encountering an “Invalid image” error frequently while working with the GPT-4 Vision API. I’m using image URLs to include pictures in my requests. Here’s a simplified version of my request structure, with specific details omitted for data protection:

I try to send this to an assistand message thread.

{
  "model": "gpt-4-vision-preview",
  "messages": [
    {
      "role": "user",
      "content": [
        {"type": "text", "text": "Please describe the contents of this image."},
        {"type": "image_url", "image_url": {"url": "hereIsACorrectFormattedURL","detail":"auto"}},
        {"type": "image_url", "image_url": {"url": "hereIsACorrectFormattedURL","detail":"auto"}}
      ]
    }
  ]
}

Despite the URLs being correct and the images being accessible via a web browser, I consistently receive the following error message: "

"error": {
    "message": "Invalid 'content[1].image_url.url'.",
    "type": "invalid_request_error",
    "param": "content[1].image_url.url.url",
    "code": "invalid_value"
  }

Watch for te double url.url part returning from the API. Is this a bug?

I’ve tried converting the images to Base64-encoded strings but I ran into other issues with this. Also those images are quite large as bas64 so it would be nonsense to do this.

Has anyone else experienced this or have any troubleshooting tips? Are there specific settings or formats that have proven more effective in circumventing this issue? Any help or insight would be greatly appreciated!

Thank you in advance!

How big are the images? Try reducing their dimensions and see what happens.

I did that with 512px. So size would not be the challenge.

Welcome to the dev forum @scubaben

This can happen when the site doesn’t allow OpenAI’s scraper bot to access the image.

Try passing the images locally by downloading them first and then including them in your API call as base64 encoded.