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 the local file path; it does not upload a large file automatically.
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

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