> ## Documentation Index
> Fetch the complete documentation index at: https://phidatainc.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

# PDF Input File Upload

> Attach a local PDF file to an OpenAI chat agent and ask it to suggest a recipe from the document.

Pass a local PDF as base64-inlined file input to an OpenAI Chat agent.

<Warning>
  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.
</Warning>

```python pdf_input_file_upload.py theme={null}
"""
In this example, we upload a PDF file to Google GenAI directly and then use it as an input to an agent.
"""

from pathlib import Path

from agno.agent import Agent
from agno.media import File
from agno.models.openai import OpenAIChat

# ---------------------------------------------------------------------------
# Create Agent
# ---------------------------------------------------------------------------

pdf_path = Path(__file__).parent.joinpath("ThaiRecipes.pdf")

# Pass the local PDF file path directly; the client will inline small files or upload large files automatically
agent = Agent(
    model=OpenAIChat(id="gpt-4o"),
    markdown=True,
    add_history_to_context=True,
)

agent.print_response(
    "Suggest me a recipe from the attached file.",
    files=[File(filepath=str(pdf_path))],
)

# ---------------------------------------------------------------------------
# Run Agent
# ---------------------------------------------------------------------------

if __name__ == "__main__":
    pass
```

## Run the Example

<Steps>
  <Snippet file="create-venv-step.mdx" />

  <Step title="Install dependencies">
    ```bash theme={null}
    uv pip install -U agno openai
    ```
  </Step>

  <Step title="Export your OpenAI API key">
    <CodeGroup>
      ```bash Mac/Linux theme={null}
      export OPENAI_API_KEY="your_openai_api_key_here"
      ```

      ```bash Windows theme={null}
      $Env:OPENAI_API_KEY="your_openai_api_key_here"
      ```
    </CodeGroup>
  </Step>

  <Step title="Download the sample PDF">
    Download `ThaiRecipes.pdf` next to the saved script:

    ```bash theme={null}
    python -c "from urllib.request import urlretrieve; urlretrieve('https://agno-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf', 'ThaiRecipes.pdf')"
    ```
  </Step>

  <Step title="Update the model">
    Replace `OpenAIChat(id="gpt-4o")` with `OpenAIChat(id="gpt-5.4-mini")` in the saved file.
  </Step>

  <Step title="Run the example">
    Save the code above as `pdf_input_file_upload.py`, then run:

    ```bash theme={null}
    python pdf_input_file_upload.py
    ```
  </Step>
</Steps>

Full source: [cookbook/90\_models/openai/chat/pdf\_input\_file\_upload.py](https://github.com/agno-agi/agno/blob/main/cookbook/90_models/openai/chat/pdf_input_file_upload.py)
