Agent with S3 Pre-signed URL Input
Pass files from AWS S3 to a Gemini agent using a pre-signed URL with File(url=...).
Code
"""S3 pre-signed URL input with Gemini.
Pass files from S3 using pre-signed URLs without downloading.
Requires Gemini 3.x models. File limits vary by model and media type.
"""
import boto3
from agno.agent import Agent
from agno.media import File
from agno.models.google import Gemini
s3_client = boto3.client("s3")
presigned_url = s3_client.generate_presigned_url(
"get_object",
Params={
"Bucket": "agno-public",
"Key": "recipes/ThaiRecipes.pdf",
},
ExpiresIn=3600,
)
agent = Agent(
model=Gemini(id="gemini-3.5-flash"),
markdown=True,
)
agent.print_response(
"What is this document about? Answer in one sentence.",
files=[
File(
url=presigned_url,
mime_type="application/pdf",
)
],
)The URL input limit is 100 MB per request, with stricter limits for some file types and models. This PDF example is subject to the 50 MB PDF limit.
Usage
Set up your virtual environment
uv venv --python 3.12
source .venv/bin/activateSet your credentials
export GOOGLE_API_KEY=xxx
export AWS_ACCESS_KEY_ID=xxx
export AWS_SECRET_ACCESS_KEY=xxxInstall dependencies
uv pip install -U google-genai agno boto3Run Agent
Save the code above as s3_url_file_input.py, then run:
python s3_url_file_input.py