Works just dandy. The problem is the poor validation by the API Python library.
import requests, os, json
body = {
"model": "gpt-4-vision-preview",
"max_tokens": 100,
"top_p": 1e-7,
"temperature": 1e-7,
"messages": [
{
"role": "user",
"content": [
"what's in the image?",
{
"type": "image_url",
"image_url": "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f3/Starship_SN16.jpeg/397px-Starship_SN16.jpeg",
},
],
}
],
}
apikey = os.environ.get('OPENAI_API_KEY')
headers = {
"Authorization": f"Bearer {apikey}",
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:125.0) Gecko/20100101 Firefox/126.0",
"Accept": "*/*",
"OpenAI-Beta": "assistants=v2",
}
url = "https://api.openai.com/v1/chat/completions"
response = requests.post(url, headers=headers, json=body)
if response.status_code != 200:
print(f"HTTP error {response.status_code}: {response.text}")
else:
print(json.dumps(response.json(), indent=3))
response:
{
“id”: “chatcmpl-1234”,
“object”: “chat.completion”,
“created”: 1718724899,
“model”: “gpt-4-1106-vision-preview”,
“choices”: [
{
“index”: 0,
“message”: {
“role”: “assistant”,
“content”: “The image shows a large, metallic rocket standing vertically on what appears to be a launch or test stand. This is the SpaceX Starship, a fully reusable spacecraft designed for missions to Earth orbit, Mars, and beyond. The rocket has a distinctive shiny, stainless steel exterior and features aerodynamic flaps near the top and bottom. The structure is quite tall and cylindrical, with a conical nose section. The environment suggests it could be at a SpaceX facility, likely in preparation for testing or as part”
},
“logprobs”: null,
“finish_reason”: “length”
}
],…
It is refusal by gpt-4o that is the problem. Inconsistent API by OpenAI.