Gemini media recognition

Send images, PDFs, audio or video to Gemini and ask questions about them.

POSThttps://your-instance.com/v1beta/models/{model}:generateContent

The same endpoint accepts non-text parts. Inline the bytes as base64 with the right MIME type and the model reads them alongside your question — this is how you get video and PDF understanding rather than generation.

Accepted media

KindMIME typeTypical use
Imageimage/png, image/jpeg, image/webpDescribe, extract text, compare
Documentapplication/pdfSummarise or query a document
Audioaudio/mp3, audio/wav, audio/oggTranscribe, summarise, answer about a recording
Videovideo/mp4, video/mov, video/webmDescribe the footage, find a moment, summarise

Asking about a video

import base64

with open("clip.mp4", "rb") as f:
    data = base64.b64encode(f.read()).decode()

response = client.models.generate_content(
    model="gemini-3-pro",
    contents=[{
        "parts": [
            {"inline_data": {"mime_type": "video/mp4", "data": data}},
            {"text": "What happens in this clip?"},
        ]
    }],
)

print(response.text)