What's the API call to get gpt4 to analyse an attached PDF file?

I can make an API by attaching an image by base64 encoding it with the code block below. How can I do the same but for PDFs; I want to attach a PDF and GPT to give me a summary of the PDF. Do I modify the type parameter below? I can’t find the docs for this anywhere. I heard 4 months ago GPT4 can now take PDFs.

Thanks!

    payload = {
    "model": "gpt-4-vision-preview",
    "messages": [
        {
        "role": "user",
        "content": [
            {
            "type": "text",
            "text": "Tell me the results of my blood test report."
            },
            {
            "type": "image_url", # CHANGE THIS?
            "image_url": {
                "url": f"data:image/jpeg;base64,{base64_image}"
            }
            }
        ]
        }
    ],
    "max_tokens": 300
    }

    response = requests.post("https://api.openai.com/v1/chat/completions", headers=headers, json=payload)

Ah, well, you’d have to use assistants. (but a better starting point would probably be the playground https://platform.openai.com/playground?mode=assistant )

the raw endpoints can’t do anything with your pdf, you’d have to OCR it yourself first.

This answer is more than a year old , and the models changed quite a bit since then.

Is this improved now (Aug 2025), i.e do we still need to pre-process PDF files?

Yes, much has changed. No need to pre-process. Here is what I do (using curl):

{“model”: “gpt-5-mini”,
“reasoning”: {“effort”: “Reasoning Effort goes here”},
“text”: {“verbosity”: “Verbosity goes here”},
“instructions”: “Instructions goes here”,
“input”: [{“role”: “user”,“content”: [{“type”: “input_file”, “filename”: “File name goes here”, “file_data”:“data:application/pdf;base64, Base64 file goes here”},
{“type”: “input_text”, “text”: “Your question goes here.”}]}]
}

Gpt-5-mini works great.