Wrong "The image data you provided does not represent a valid image" Error when sending only JPG image links
I looked into this a bit. My read is: a duplicate image URL should not, by itself, make the request invalid**.** If the same URL is a valid, publicly fetchable JPEG, sending it twice should be OK.
That error message usually means something more specific: when the API tried to read one of the image inputs, the bytes it received did not decode as a supported image (jpeg/png/gif/webp). A URL ending in .jpg is not enough to guarantee that. For example, the OpenAI server may fetch the URL and receive an HTML error page, a 403/429 hotlink-protection page, a redirect/login page, a truncated response, or bytes with the wrong content.
A quick way to narrow this down:
- Try the same request with each image URL one at a time.
- From a clean/non-browser environment, run something like:
curl -L -D headers.txt -o image.bin ``'YOUR_IMAGE_URL'
file image.bin
python - <<``'PY'
from PIL import Image
Image.open(``"image.bin"``).verify()
print``(``"image decodes OK"``)
PY
- Check that the downloaded body is actually a JPEG, not HTML/XML/text.
- If it only fails when the same valid image URL is repeated , capture the failing OpenAI request_id and share it with support / in this thread. That would be worth investigating as a bug.
- As a workaround, try sending the image as a data: URL / base64 image, or make sure the image is hosted at a public URL that allows server-side fetching.
One nuance: browsers can succeed where API servers fail because your browser may have cookies, a different user-agent, cached content, or access from a different IP/location.
So I’d classify this as: expected error if the backend fetch got non-image/corrupt bytes; probable bug or misleading error if the URL is publicly fetchable as a valid JPEG and merely duplicating it causes the failure.
Discussion in the ATmosphere