Part type to represent all content, making it straightforward to mix text and media in the same message.
The MediaPart type
Non-text content is represented as a MediaPart:
Part objects. Each part is either a TextPart ({ text: string }) or a MediaPart.
Images
From a URL
Pass a publicly accessible image URL directly:From a base64-encoded buffer
For local files or dynamically loaded images, encode the content as a base64 data URI:Shorthand for multipart arrays
You can also pass the parts array directly toai.generate():
Python example
Go example
Audio input
Models that support audio input (such as Gemini 1.5 Pro and later) accept audio files using the sameMediaPart structure:
Video input
Video is supported via URL or base64, with the same approach. Large video files are best referenced by URL:PDF and document input
Gemini models can also process PDF documents:Model capabilities
Not all models support multimodal input. Each model exposes its capabilities in theModelInfo.supports metadata:
supports object includes:
Multimodal support depends on the model. Gemini 1.5 and 2.x models support images, audio, video, and PDF input. Older or text-only models will return an error if media parts are included in the prompt. Check the plugin documentation for the specific model you are using.
Combining multimodal input with structured output
You can combine multimodal input with structured output to extract typed data from images:Structured output
Extract typed data from images or documents.
Google GenAI plugin
Gemini model capabilities and configuration.
Models
How model capability metadata works.
Streaming
Stream multimodal responses.
