Skip to content

Conversation

@dprov
Copy link
Contributor

@dprov dprov commented Jul 22, 2025

@dprov dprov requested a review from DouweM July 23, 2025 12:32
@dprov dprov requested a review from DouweM July 24, 2025 02:31
@DouweM DouweM changed the title Support google file api urls Support passing files uploaded to Gemini Files API and setting custom media type Jul 24, 2025
@DouweM
Copy link
Collaborator

DouweM commented Jul 24, 2025

@dprov Thanks!

@DouweM DouweM merged commit fc6a2b2 into pydantic:main Jul 24, 2025
18 checks passed
KRRT7 pushed a commit to aseembits93/pydantic-ai that referenced this pull request Jul 24, 2025
@marmor7
Copy link

marmor7 commented Nov 20, 2025

@DouweM
I think this code:

self.system == 'google-gla' and not item.url.startswith(r'https://generativelanguage.googleapis.com/v1beta/files')

conflicts with the docs here:
https://ai.pydantic.dev/input/#user-side-download-vs-direct-file-url

Maybe the docs needs to be updated?

Also, would be nice to get an example code in the docs showing a file being uploaded to Gemini and then referenced in a pydantic-ai message, it's not straightforward to me.

@DouweM
Copy link
Collaborator

DouweM commented Nov 20, 2025

@marmor7 Good point, it's explained in the code comment but not the docs:

# google-gla does not support passing file urls directly, except for youtube videos
# (see above) and files uploaded to the file API (which cannot be downloaded anyway)
self.system == 'google-gla'
and not item.url.startswith(r'https://generativelanguage.googleapis.com/v1beta/files')

Also, would be nice to get an example code in the docs showing a file being uploaded to Gemini and then referenced in a pydantic-ai message, it's not straightforward to me.

Good point; I'm glad you figured it out eventually but the next person should have an easier time.

Would you be up for adding both to the docs?

@marmor7
Copy link

marmor7 commented Nov 20, 2025

@DouweM sure, what about this:
#3492

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support passing files uploaded to Gemini Files API

3 participants