Skip to main content
Google has shut down gemini-2.0-flash-exp. The source also passes a legacy uploaded File object to Image.content, which accepts bytes in Agno v2.7.4. Apply both edits below before running. See Gemini 2.0 Flash model status.
image_input_file_upload.py

Run the Example

1

Set up your virtual environment

2

Install dependencies

3

Export your Google API key

4

Update the Gemini model

Replace gemini-2.0-flash-exp with gemini-3.5-flash in the saved file.
5

Use the local image directly

Remove from google.generativeai import upload_file, from google.generativeai.types import file_types, and the image_file = upload_file(image_path) assignment and print. Replace Image(content=image_file) with Image(filepath=image_path).
6

Download the sample image

Download the image expected by the saved script:
7

Run the example

Save the code above as image_input_file_upload.py, then run:
Full source: cookbook/90_models/google/gemini/image_input_file_upload.py