GPT-4 with Vision - Can't view image URL

What am I not understanding here? I thought the GPT-4 with vision (new model) was capable of evaluating an image from a URL. I am building in PHP. Here’s my curl:

$data = [
    "model" => "gpt-4-turbo",
    "messages" => [
        [
            "role" => "user",
            "content" => "What’s in this image?" . $fileUrl
        ]
    ],
    "max_tokens" => 3000
];

// Encode the data to JSON
$jsonData = json_encode($data);

// Initialize cURL
$ch = curl_init('https://api.openai.com/v1/chat/completions');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $jsonData);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    'Authorization: Bearer ' . $openai_api_key,
    'Content-Type: application/json'
]);

// Execute the request
$response = curl_exec($ch);
curl_close($ch);

$fileUrl equates to a fully qualified URL. The response I get is “I’m sorry for any confusion, but as an AI text model, I can’t directly view images or URLs. However, if you describe the image to me, I could help provide information or answer questions based on your description.”

Am I misunderstanding something here?

Can you format your message using Vision format and try again?

curl https://api.openai.com/v1/chat/completions \
  -H "Content-Type: application/json" \
  -H "Authorization: Bearer $OPENAI_API_KEY" \
  -d '{
    "model": "gpt-4-turbo",
    "messages": [
      {
        "role": "user",
        "content": [
          {
            "type": "text",
            "text": "What’s in this image?"
          },
          {
            "type": "image_url",
            "image_url": {
              "url": '.$fileUrl.'
            }
          }
        ]
      }
    ],
    "max_tokens": 300
  }'
6 Likes

Thank you. I got this to work using the following.

$data = [
    "model" => "gpt-4-turbo",
    "messages" => [
        [
            "role" => "user",
            "content" => [
                [
                    "type" => "text",
                    "text" => "What’s in this image?"
                ],
                [
                    "type" => "image_url",
                    "image_url" => [
                        "url" => $fileUrl
                    ]
                ]
            ]
        ]
    ],
    "max_tokens" => 300
];