Sending a PDF to OpenAI /responses endpoint causes 500 error

Scott Smith 25 Reputation points
2025-04-24T17:53:17.2266667+00:00

Hi

I'm trying to use the /responses endpoint of the OpenAI service to analyze a PDF file but it is responding with an Internal Error. I am using the Python openai library (openai-1.76.0). The last request I did (request ID e415f048-be0e-4bd7-9504-81b51a156558) was like this:

response = client.responses.create(

model=deployment,

input=[

{

"role": "user",

"content": [

{

"type": "input_file",

"filename": "page_001.pdf",

"file_data": f"data:application/pdf;base64,{base64_pdf}"

},

{ "type": "input_text", "text": "What kind of document is in this PDF?" }

]

}

]

)

with the response:

{

"error":{

"message":"The server had an error processing your request. Sorry about that! You can retry your request, or contact us through our help center at oai-assistants@microsoft.com if you keep seeing this error. (Please include the request ID e415f048-be0e-4bd7-9504-81b51a156558 in your email.)",

"type":"server_error",

"param":"None",

"code":"None"

}

}

My OpenAI service is in the UK South region and I'm using gpt-4o and targetting version 2025-03-01-preview.

I've tried other requests including just asking a question and supplying an image which I ask about and they do not cause the error. I only get it when uploading a PDF.

thanks

Azure OpenAI in Foundry Models

Answer accepted by question author
Pavankumar Purilla 11,655 Reputation points Moderator
2025-04-28T05:34:50.7766667+00:00

Hi Scott Smith,

The reason you're getting a 500 Internal Server Error when sending a PDF to the /responses endpoint is because the Azure OpenAI service does not currently support PDFs as a valid input_file type. The /responses endpoint only accepts certain file types, mainly images like PNG and JPEG, but not PDFs. That’s why sending an image works, but sending a PDF causes the server to crash. To work around this, you should first extract the text content from the PDF using a Python library such as PyMuPDF, PyPDF2, or pdfplumber. Once you have the extracted text, you can send it to the /responses endpoint as input_text instead of input_file. This way, the model can read and analyze the contents of the PDF properly. In short, PDFs must be converted into plain text before sending, because direct PDF uploads are not supported in the /responses API.

I hope this information helps. Thank you!

Was this answer helpful?

0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.