GPT-4-Vision Error - BadRequestError: 400 Invalid image

Using gpt-4-vision-preview I’m getting a BadRequestError: 400 Invalid image error when the image url has some encoding. Specifically, I’m using a getDownloadUrl() from Firebase storage which has some characters encoded (%2F). I can’t replace this with “/” because the URL becomes invalid.

Here a sample url: https://firebasestorage.googleapis.com/v0/b/MY_PROJECT.appspot.com/o/JD05o0EuRyb2QPqkGAEew5unrjl1%2Flogs%2F24391b95-f386-4ffc-8dea-3dcc88714ee9.jpg?alt=media&token=aea4de99-270f-436b-86ca-5325d5a85730

The image URL is currently a 404.

Indeed putting forward slashes in is instead a 400.

However, the “token” in the URL indicates some authentication going on, does it work in a private or different browser? Another site that you can upload from a URL like imgur.com?

With the python library you can get raw response, and then get the text of the request to see what was sent to the API if you are using that library.

You could also send such a URL to your own domain and see from the log if OpenAI is rewriting the %2F to something invalid.

Best is just download yourself and submit to the API as base64. Too much could be blocked just with the request coming from OpenAI’s gpt-bot that respects robots.txt.

1 Like

[the image url i provided is invalid - just a sample to illustrate the encoding].

My suspicion is that the API has a problem with encoded URL characters. It works as expected if there are now encoded characters, base64 string also works as expected.

My issue is that, for performance reasons, I don’t have the time to re-upload the image elsewhere. I must use the Firebase Storage download url, which as per Firebase documentation, must have have the %2F encoding.

Did you ever figure this out? I’m running into a similar issue.

did anyone find a solution to this? currently facing the same issue.

Download the image to your own server/environment and then specify the image in base64 when making the vision API request, that way you can handle any missing/damaged/unavailable images in your own code.

Apologies for the late response. No I did not find a solution to this and ended up use a base64 encoded version of the image instead. I’m not a 100% but it appears that the token query parameter in the URL is only valid when there is a “real” user(agent). That said, I believe the OpenAI team could implement a solution on there end to make sure that URLs like this are valid.

1 Like