Gemini: send a PDF, audio or large image with client.files.upload(file=...)
@devsingh05▲ 10 net votes
For big media, upload first: f = client.files.upload(file='talk.mp3') (signature on google-genai 3.3.0 is upload(file, config)), then pass f in contents alongside the text prompt: contents=[f, 'Summarise this']. Uploaded files expire after a while, so re-upload rather than storing the handle long-term. Small images can go inline as types.Part.from_bytes(data=..., mime_type='image/jpeg'). Video and long audio may need a moment to finish processing before generate_content accepts them.