1"""S3 pre-signed URL input with Gemini.
2
3Pass files from S3 using pre-signed URLs without downloading.
4Supports files up to 100MB. Requires Gemini 3.x models.
5"""
6
7import boto3
8from kern.agent import Agent
9from kern.media import File
10from kern.models.google import Gemini
11
12s3_client = boto3.client("s3")
13presigned_url = s3_client.generate_presigned_url(
14 "get_object",
15 Params={
16 "Bucket": "kern-public",
17 "Key": "recipes/ThaiRecipes.pdf",
18 },
19 ExpiresIn=3600,
20)
21
22agent = Agent(
23 model=Gemini(id="gemini-3-flash-preview"),
24 markdown=True,
25)
26
27agent.print_response(
28 "What is this document about? Answer in one sentence.",
29 files=[
30 File(
31 url=presigned_url,
32 mime_type="application/pdf",
33 )
34 ],
35)