I am making a chatbot. On receiving image inputs from the user, the image is uploaded to a public supabase storage bucket ( there are no restrictions on image access), then the image URL is retrieved and the url is used as a parameter send to the chat completion endpoint. I am using the gpt-4o-turbo model. When I send a dynamically generated URL like this I get an error: Error in createCompletion: BadRequestError: 400 Invalid image.
However if I take this exact same URL that caused the bad request and hardcode it as a parameter, I get a valid response.
Why is this happening? The URL strings are the exact same. I even added a long delay between the URL creation and the calling of the API, so that is not the issue. I have also checked that the dynamically generated URL is a string as well.
The types of the URL are the same.
The image size is very small so token size is not an issue either.
It is also a JPG image so image type should not be an issue too.
The bucket is public so access to the image should not be an issue either, if access permissions was the problem then I would get invalid responses when I hardcoded the URL too.
These are the request parameters with the dynamically generated URL that gave an invalid response:
Prepared userMessage: {
"role": "user",
"content": [
{
"type": "text",
"text": "what is this"
},
{
"type": "image_url",
"image_url": {
"url": "https://bucketId.supabase.co/storage/v1/object/public/chat-images/imageId.jpg"
}
}
]
}
And this is the request parameters with the hardcoded URL that gave a valid response:
Prepared userMessage: {
"role": "user",
"content": [
{
"type": "text",
"text": "what is this"
},
{
"type": "image_url",
"image_url": {
"url": "https://bucketId.supabase.co/storage/v1/object/public/chat-images/imageId.jpg"
}
}
]
}
Would appreciate any help Can dm the image URL as well