PDF generated by Code Execution cannot be passed back as input

Hi Google Team,

I created a PDF file using the Code Execution tool, and when I try to pass the generated PDF back in a subsequent generateContent api request, I am getting the following exact error:

[
    {
        "error": {
            "code": 400,
            "message": "The mime type: application/pdf is not supported for code execution.",
            "status": "INVALID_ARGUMENT"
        }
    }
]

I tried passing the PDF in both ways:

  • Using fileData with the PDF fileUri
  • Using inlineData with the PDF content

However, both approaches are throwing the same error.

I also tried this with multiple models:

  • Gemini 3.5 Flash
  • Gemini 3.6 Flash
  • Gemini 3.1 Flash-Lite
  • Gemini 3.1 Pro Preview

I am getting the same error with all of these models.

Earlier, this was working for us, and we were able to pass the generated PDF back to generateContent api and modify it using Code Execution. Recently, the same request has started failing with the above error.

In this previous discussion, it was suggested to convert the file to PDF and then use the PDF as the input:

Could you please help us understand why PDF input is no longer working with Code Execution? Has there been any recent change or restriction regarding PDF files as input?

If PDF input with Code Execution is still supported, could you please help us understand why we are now receiving this error with both fileData and inlineData across the above models?

Also, could you please let us know if there is any solution or workaround available for this? We would really appreciate your guidance on the recommended approach.

Thank you for your help.

Code execution and PDF document understanding are mutually exclusive in Gemini API, and this has been reported to the Gemini team over a year ago, see Code execution switched off if a PDF is attached