Issue with Native PDF input (Base64) in gpt-4o - Error: invalid 'input[0].content[1].file_data'

Hi everyone,

I’m trying to use the new native PDF processing capability with gpt-4o by sending a Base64 encoded file directly in the payload. However, the API keeps returning a 400 Bad Request with the following error:

"body": { "error": { "message": "invalid 'input[0].content[1].file_data'.", "type": "invalid_request_error", "param": "input[0].content[1].file_data", "code": "invalid_value" } }

I’ve checked the documentation, but the structure for the new input and input_file parameters seems to be causing this validation error. Here is the schema I am using (sensitive values omitted):

{
“model”: “gpt-4o”,
“text”: {
“format”: {
“type”: “json_object”
}
},
“input”: [
{
“role”: “user”,
“content”: [
{
“type”: “input_text”,
“text”: “[Detailed forensic prompt instructions here]”
},
{
“type”: “input_file”,
“filename”: “document.pdf”,
“file_data”: “[Base64_Encoded_PDF_String]”
}
]
}
]
}

The model used is gpt-4o.

  1. I am hitting the /v1/chat/completions endpoint (or the latest Responses API equivalent).

Has the schema for file_data or input_file changed recently? Does it require a specific API version header?

Any help would be appreciated!

You need to send a data URI, not just bare base64.

Does the error text continue, with "Expected a base64-encoded data URL with an application/pdf MIME type (e.g. 'data:application/pdf;base64,SGVsbG8sIFdvcmxkIQ=='), but got an invalid base64-encoded value.

2 Likes