Video Input (Local File Upload)

Code

1from pathlib import Path
2
3from kern.agent import Agent
4from kern.media import Video
5from kern.models.google import Gemini
6
7agent = Agent(
8 model=Gemini(id="gemini-2.0-flash-exp"),
9 markdown=True,
10)
11
12# Get sample videos from https://www.pexels.com/search/videos/sample/
13video_path = Path(__file__).parent.joinpath("sample_video.mp4")
14
15agent.print_response("Tell me about this video?", videos=[Video(filepath=video_path)])

Usage

Set up your virtual environment

1uv venv --python 3.12
2source .venv/bin/activate
1uv venv --python 3.12
2.venv\Scripts\activate

Set your API key

1export GOOGLE_API_KEY=xxx

Install dependencies

1uv pip install -U google-genai kern-ai

Run Agent

1python cookbook/11_models/google/gemini/video_input_local_file_upload.py