Chat Completions: a happy endpoint
openai.BadRequestError: Error code: 400 - {'error': {'message': "Invalid image URL: 'messages[0].content[0].image_url.url'. Expected a base64-encoded data URL with an image MIME type (e.g. 'data:image/png;base64,aW1nIGJ5dGVzIGhlcmU='), but got a value without the 'data:' prefix.", 'type': 'invalid_request_error', 'param': 'messages[0].content[0].image_url.url', 'code': 'invalid_value'}}
The API is supposed to detect either an internet URL or a data URI in the string.
What should be returned is the same error reached by sending base64:
openai.BadRequestError: Error code: 400 - {'error': {'message': 'Invalid content type. image_url is only supported by certain models.', 'type': 'invalid_request_error', 'param': 'messages.[0].content.[1].type', 'code': None}}
Further requests got working responses with all models, by URL or by base64. This or the first post’s. So it is not some new rule of a site blocking OpenAI with robots.txt
or blocking outright.
if you_have_a_URL:
# Use a remote image URL for the test
user_message = [
{
"role": "user",
"content": [
{
"type": "image_url",
"image_url": {
"url": "https://avatars.githubusercontent.com/u/1?v=4"
},
},
{"type": "text", "text": "describe the content of images"},
],
}
]
--- Testing Model: o3-2025-04-16 ---
Input Tokens: 236
Response: The image is a well-lit portrait set against a dark, neutral background: • A ma
[elapsed: 6.1 seconds]
--- Testing Model: o4-mini-2025-04-16 ---
Input Tokens: 399
Response: The image is a close-up studio portrait of an adult man. He has short, wavy brow
[elapsed: 3.0 seconds]
--- Testing Model: gpt-4.1-2025-04-14 ---
Input Tokens: 267
Response: The image shows a man with short, curly brown hair and light facial hair. He is
[elapsed: 2.8 seconds]
--- Testing Model: gpt-4.1-mini-2025-04-14 ---
Input Tokens: 378
Response: The image shows a man with short, curly brown hair and light facial hair. He has
[elapsed: 1.5 seconds]
--- Testing Model: gpt-4.1-nano-2025-04-14 ---
Input Tokens: 567
Response: This is a portrait photograph of a man with short, curly dark hair and a light b
[elapsed: 5.5 seconds]
--- Testing Model: gpt-4.5-preview-2025-02-27 ---
Input Tokens: 267
Response: The image shows a portrait of a man with short, curly brown hair and a slight be
[elapsed: 5.5 seconds]
--- Testing Model: o1-2024-12-17 ---
Input Tokens: 236
Response: The image shows a man facing the camera against a dark background. He appears to
[elapsed: 8.6 seconds]
--- Testing Model: gpt-4o-2024-11-20 ---
Input Tokens: 267
Response: The image shows a man with short, curly dark hair and a beard. He is wearing a d
[elapsed: 1.8 seconds]
--- Testing Model: gpt-4o-2024-08-06 ---
Input Tokens: 267
Response: The image shows a man with short, curly hair and a beard. He is wearing a dark t
[elapsed: 2.7 seconds]
--- Testing Model: gpt-4o-mini-2024-07-18 ---
Input Tokens: 8512
Response: The image features a man with short, curly hair and a light beard, smiling at th
[elapsed: 2.1 seconds]
--- Testing Model: gpt-4o-2024-05-13 ---
Input Tokens: 267
Response: The image shows a man with short, curly dark hair and a light beard. He is weari
[elapsed: 1.6 seconds]
--- Testing Model: gpt-4-turbo-2024-04-09 ---
Input Tokens: 267
Response: The image shows a close-up portrait of a man with a friendly expression. He has
[elapsed: 6.2 seconds]
--- All tests complete. ---
Responses, “works for me”…
I produced a similar script using Responses and the internet URL, all successful just now.
--- Testing Model: o3-pro-2025-06-10 ---
Input Tokens: 266
Response: The image shows a head-and-shoulders portrait of an adult man with short, curly
[elapsed: 23.9 seconds]
--- Testing Model: o3-2025-04-16 ---
Input Tokens: 236
Response: The image shows a man with short, curly brown hair and light facial stubble. He
[elapsed: 8.3 seconds]
--- Testing Model: o4-mini-2025-04-16 ---
Input Tokens: 399
Response: The image is a tightly framed head-and-shoulders portrait of an adult man agains
[elapsed: 8.1 seconds]
--- Testing Model: gpt-4.1-2025-04-14 ---
Input Tokens: 267
Response: The image shows a man with short, curly brown hair and light skin. He has green
[elapsed: 2.9 seconds]
--- Testing Model: gpt-4.1-mini-2025-04-14 ---
Input Tokens: 378
Response: The image shows a man with short, curly brown hair and light facial hair. He is
[elapsed: 3.8 seconds]
--- Testing Model: gpt-4.1-nano-2025-04-14 ---
Input Tokens: 567
Response: The image features a man with short, curly dark hair and a light beard. He is sm
[elapsed: 1.6 seconds]
--- Testing Model: gpt-4.5-preview-2025-02-27 ---
Input Tokens: 267
Response: The image is a portrait of a man with short, curly brown hair and a slight beard
[elapsed: 7.6 seconds]
--- Testing Model: o1-2024-12-17 ---
Input Tokens: 44
Response: It appears to be a portrait-style photo of an adult male viewed from the shoulde
[elapsed: 12.3 seconds]
--- Testing Model: gpt-4o-2024-11-20 ---
Input Tokens: 267
Response: The image shows a man with short, curly dark hair and a beard, wearing a dark-co
[elapsed: 2.4 seconds]
--- Testing Model: gpt-4o-2024-08-06 ---
Input Tokens: 267
Response: The image shows a person with short, curly hair and a beard, wearing a dark t-sh
[elapsed: 2.2 seconds]
--- Testing Model: gpt-4o-mini-2024-07-18 ---
Input Tokens: 8512
Response: The image features a man with short, curly hair and a light beard, smiling at th
[elapsed: 2.4 seconds]
--- Testing Model: gpt-4o-2024-05-13 ---
Input Tokens: 267
Response: The image is a portrait of a man with short, curly dark hair and a light beard.
[elapsed: 2.7 seconds]
--- Testing Model: gpt-4-turbo-2024-04-09 ---
Input Tokens: 267
Response: The image shows a close-up portrait of a Caucasian man with a friendly expressio
[elapsed: 9.6 seconds]
--- All tests complete. ---
Issue with the first post’s Image URL
Try this for the same picture:
https://upload.wikimedia.org/wikipedia/commons/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg
NOT:
"https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
Then success…
--- Testing Model: o3-pro-2025-06-10 ---
Input Tokens: 1116
Response: The image shows a tranquil, wide-open landscape on a bright, sunny day. A narrow
[elapsed: 56.6 seconds]
--- Testing Model: o3-2025-04-16 ---
Input Tokens: 986
Response: The image shows a straight wooden boardwalk running through a lush, green meadow
[elapsed: 6.4 seconds]
Something about the API doesn’t like the first post’s URL, the one from the API Reference example, ERROR: Error code: 400 - {'error': {'message': 'Failed to download file from https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg.', 'type': 'invalid_request_error', 'param': 'url', 'code': 'invalid_value'}}