Skip to main content
Pass a local PDF as base64-inlined file input to an OpenAI Chat agent.
The source docstring incorrectly refers to Google GenAI. OpenAIChat base64-inlines a local file path, contrary to the source comment’s automatic large-file upload claim. The source also uses deprecated gpt-4o. Replace the model before running.
pdf_input_file_upload.py

Run the Example

1

Set up your virtual environment

2

Install dependencies

3

Export your OpenAI API key

4

Download the sample PDF

Download ThaiRecipes.pdf next to the saved script:
5

Update the model

Replace OpenAIChat(id="gpt-4o") with OpenAIChat(id="gpt-5.4-mini") in the saved file.
6

Run the example

Save the code above as pdf_input_file_upload.py, then run:
Full source: cookbook/90_models/openai/chat/pdf_input_file_upload.py