Can you upload PDF and Image in one request?

Can you upload a PDF and Image in base64 in a single request?

Looking at this documentation: https://platform.openai.com/docs/guides/pdf-files?api-mode=chat

Sure, you can.

Here is an example.

from openai import OpenAI
client = OpenAI()

response = client.responses.create(
  model="gpt-4.1-mini",
  input=[
    {
      "role": "user",
      "content": [
        {
          "type": "input_image",
          "image_url": "data:image/jpeg;base64,..."
        },
        {
          "type": "input_text",
          "text": "describe this image. And also the pdf file."
        },
        {
          "type": "input_file",
          "filename": "teste-pdf.pdf",
          "file_data": "data:application/pdf;base64,..."
        }
      ]
    }
      ]
    }
  ],
  text={
    "format": {
      "type": "text"
    }
  },
  reasoning={},
  tools=[],
  temperature=1,
  max_output_tokens=2048,
  top_p=1,
  store=True
)

You can try it on playground.

1 Like