For past week or so, I’ve been getting BadRequestErrors consistently, and exclusively on portrait - orientation pictures. Image formats and sizes are all correct, and I can very consistently reproduce this error, which occurs on gpt-4o, gpt-4o-mini, and gpt-4-turbo.
BadRequestError: 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’: ‘image_parse_error’}}
For low res mode, we expect a 512px x 512px image. For high res mode, the short side of the image should be less than 768px and the long side should be less than 2,000px.
– Docs
Hi @sps , thanks for the note. I am using high res mode, so shouldn’t the model automatically rescale large images? As an additional point – the images causing issues are un-altered taken on iphones (of various device models).
Hi @sps , correct, they are being converted from HEIC to jpg, stored as jpg in the bucket. @RonaldGRuckus thanks for the suggestion. I tried with a webp but unfortunately got same issue.
Strange. I’m not getting any errors with this image:
"image_description": "The image features an elegantly decorated bar with a vibrant design. The ceiling is adorned with a striped awning pattern in white and beige. The back of the bar showcases a variety of liquor bottles on shelves within an arched display, backed by floral wallpaper. In front, a marble bar counter is supported by an intricately patterned base, and it is flanked by three pink velvet bar stools. Overall, the setting conveys a chic and stylish atmosphere."
So strange, I just did the same and got the same error, "{‘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’: ‘image_parse_error’}}. Here is my code for local image:
import base64
import requests
# OpenAI API Key
api_key = os.environ.get("OPENAI_API_KEY")
# Function to encode the image
def encode_image(image_path):
with open(image_path, "rb") as image_file:
return base64.b64encode(image_file.read()).decode('utf-8')
# Path to your image
image_path = "REPLACE WITH LOCAL FILEPATH"
# Getting the base64 string
base64_image = encode_image(image_path)
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {api_key}"
}
payload = {
"model": "gpt-4o-mini",
"messages": [
{
"role": "user",
"content": [
{
"type": "text",
"text": "What’s in this image?"
},
{
"type": "image_url",
"image_url": {
"url": f"data:image/jpeg;base64,{base64_image}"
}
}
]
}
],
"max_tokens": 300
}
response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)
print(response.json())
Sorry for the multiple messages here. It occured to me that the image you downloaded from this forum may have been resized when i uploaded it (which I just confirmed – it’s much smaller than the original at 760kb vs 3.3MB). The “resized” one works on my end.
Hi i’m getting same error for my app for API call to GPT4o. Starting Aug 5th there’s been an increase where 90% of images submitted to the api returns 400 error. Even images that were used in the past without issue and no changes were made to this part of my code.
Just want to add that I am having this exact same problem as well. This is completely crippling my app and without finding any solution after scouring the web for hours, I feel like I have no choice but to turn to another model. This problem is occuring even with the old gpt-vision-preview model.