Title: How to Enable Image and PDF Analysis with ChatGPT API Version 1.33.0

I want to use the ChatGPT API to analyze PDFs and images. However, it seems that with ChatGPT API version 1.33.0 and gpt-4o, only PDF analysis is possible, and image analysis is not supported. How can I resolve this issue?

Hi. It may “seem” like images cannot be uploaded, but that is likely because you are inspecting the documentation for file search within Assistants endpoint, which is for documents.

To employ images and to pass them to the AI, they must be part of a user message that is sent, where the user message can be either text, or image with text. You would look into the AI’s endpoint documentation to see how to send them, and images must be sent only to a model that supports computer vision.

Preparing a message list for chat completions, for example, using a URL instead of a file upload method:

messages = [
{
"role": "user",
"content": [
{
    "type": "text",
    "text": "Briefly, What’s in this image?"
    },
    {
        "type": "image_url",
        "image_url":
        {
            "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/f/f3/Starship_SN16.jpeg/397px-Starship_SN16.jpeg",
            "detail": "low"
        }
    },
],
}
]

Images cannot be searched by matching text to text, so they would not function as documents.

1 Like