400 error on gpt-vision emerges out of nowhere (solved)

I get the following error message all of a sudden
Error code: 400 - {‘error’: {‘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’].”, ‘type’: ‘invalid_request_error’, ‘param’: None, ‘code’: ‘invalid_image_format’}}

Note that the sizes of my images are not larger than 20mb and that with the same code and the same images it was working before and now al of a sudden it doesn’t. What could be wrong? Thanks for helping out

This is my code:

def get_info_image(base64_image):

response = client.chat.completions.create(
  model="gpt-4-vision-preview",
  messages=[
    {
      "role": "user",
      "content": [
        {"type": "text", "text": "Dit is een nederlands talige GPT waar je foto's naar kan uploaden, deze foto's worden vervolgens beschreven in een uitgebreid verslag en interpetatie die humorvol en vlot is. De GPT output maximaal 300 tokens"},
        {
          "type": "image_url",
          "image_url": {
            "url": f"data:image/jpeg;base64,{base64_image}",
          },
        },
      ],
    }
  ],
  max_tokens=800,
)
message=response.choices[0].message.content
return message

found the error was due to hidden files being uploaded as image file.

1 Like