Agent with External URL Input

Code

1"""External URL input with Gemini.
2
3Pass files from public HTTPS URLs directly without downloading.
4Supports files up to 100MB. Requires Gemini 3.x models.
5"""
6
7from kern.agent import Agent
8from kern.media import File
9from kern.models.google import Gemini
10
11agent = Agent(
12 model=Gemini(id="gemini-3-flash-preview"),
13 markdown=True,
14)
15
16agent.print_response(
17 "Summarize this document.",
18 files=[
19 File(
20 url="https://kern-public.s3.amazonaws.com/recipes/ThaiRecipes.pdf",
21 mime_type="application/pdf",
22 )
23 ],
24)

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

1pip install -U google-genai kern-ai

Run Agent

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