Skip to content
Blog

Multimodal Inputs in ADK: Passing Images, Audio, and Video to LlmAgent

How to send images, PDFs, audio, and video into an ADK agent turn with google-genai Parts — inline bytes vs the Files API vs Cloud Storage URIs, token costs, and the streaming and tool patterns around them.

Published on • November 27, 2026

AI Assistant

Most agent conversations are text in and text out, which is why multimodal input feels like a special case — until it doesn’t. A support agent that reads the screenshot the customer attached, a meeting assistant that transcribes an audio clip, a field-service bot that looks at the photo of a damaged part: these are ordinary turns, and in ADK they are built from exactly the same primitives as a text turn.

The primitive is the types.Part. Everything a user can hand an agent — a sentence, an image, a PDF, a video, a blob produced by a tool — arrives as parts inside a types.Content. This post walks through how to build those parts correctly, when to send bytes inline versus uploading, how they travel through a Runner into an LlmAgent, and how to keep the token bill sane.

The mental model: content, parts, roles

The Gen AI SDK (which ADK’s Gemini path uses under the hood) normalises every request into a list of types.Content objects, each carrying a role (user, model, or tool) and a list of types.Part:

from google.genai import types

contents = types.Content(
    role='user',
    parts=[
        types.Part.from_text(text='What is wrong with this screenshot?'),
        types.Part.from_bytes(data=screenshot_bytes, mime_type='image/png'),
    ],
)

Three constructors cover almost everything you will write:

ConstructorUse it for
types.Part.from_text(text=...)Plain text
types.Part.from_bytes(data=..., mime_type=...)Local bytes: images, short audio, small video
types.Part.from_uri(file_uri=..., mime_type=...)Something already stored elsewhere: a gs:// object, an uploaded Files API handle

Passing a list of these (or a flat list of strings and parts) is fine — the SDK groups consecutive non-function-call parts into a single UserContent. Function-call parts are grouped separately as ModelContent, which is how a resumed turn keeps its history honest.

Passing multimodal input from an ADK agent

An LlmAgent doesn’t care where the parts came from. Whatever your application receives — an uploaded file from a web form, a camera frame from a mobile app, a clip from an object store — you turn it into a types.Content and hand it to the runner as the new message:

from google.adk.runners import Runner
from google.genai import types

async def send_image(runner: Runner, session_id: str, image_bytes: bytes, question: str):
    message = types.Content(
        role='user',
        parts=[
            types.Part.from_text(text=question),
            types.Part.from_bytes(data=image_bytes, mime_type='image/jpeg'),
        ],
    )

    async for event in runner.run_async(
        session_id=session_id,
        user_id='user-1',
        new_message=message,
    ):
        if event.content and event.content.parts:
            for part in event.content.parts:
                if part.text:
                    print(part.text, end='')

Audio and video are the same call with a different MIME type — audio/wav, audio/mpeg, video/mp4. The model decides how to interpret them; you only have to be honest about the format.

Inline bytes vs. upload vs. URI

Three ways to get media to the model, with three different failure modes:

  1. Inline (from_bytes). Simplest. The payload rides in the request body and is subject to the request size limit — inline media is capped in the low tens of megabytes, and video is what blows through it first. Good for screenshots, product photos, short voice notes.
  2. Files API (client.files.upload). The Gemini Developer API path: upload once, reference the returned file, keep it for later turns. Files are transient and must be re-used or re-uploaded after their expiry; they are not a CDN.
  3. Cloud Storage URI (from_uri). The managed/enterprise path for large or repeated assets — a folder of training videos, a nightly batch of scanned documents — where the object lives in gs:// and the request carries only a pointer.
# Large file: upload once, then point at it in every turn
uploaded = client.files.upload(file='incident-clip.mp4')

message = types.Content(
    role='user',
    parts=[
        types.Part.from_text(text='Summarise the failure sequence.'),
        types.Part.from_uri(file_uri=uploaded.uri, mime_type='video/mp4'),
    ],
)

A practical rule: if the asset is smaller than roughly 10 MB and used once, send bytes; if it is used across turns or larger than the inline limit, upload it; if it already lives in your data lake, use a URI and skip the round trip entirely.

Building parts inside a tool

Multimodal input is not only a user-input concern. A tool that fetches a diagram from a wiki, a screenshot from a monitoring system, or a voice memo from a ticket queue can return it as part of the tool response, and the next model turn sees it inline:

def fetch_dashboard_screenshot(service: str) -> dict:
    """Return the latest health screenshot for a service.

    Args:
        service (str): Service name, e.g. 'checkout-api'.
    """
    png = capture_health_panel(service)
    return {
        'status': 'success',
        'caption': f'Health panel for {service}',
        'image': types.Part.from_bytes(data=png, mime_type='image/png'),
    }

Because ADK runs your function and packages its return value into the conversation, embedding a Part keeps the visual evidence where the reasoning happens instead of round-tripping through your UI.

What the model actually receives (and charges you for)

Media is tokenised, not free-floating:

  • Images become a set of image tokens determined by resolution and tile count. Higher resolution improves OCR and small-text reading, and costs proportionally more.
  • Audio is transcribed/tokenised at a per-second rate — fine for a 30-second clip, noticeable for a two-hour recording.
  • Video is sampled frame by frame (plus audio), so token cost scales with duration. Long clips should be trimmed or summarised by a cheaper pipeline first.

Two consequences for agent design:

  1. Budget your modality. A turn with three 4K images and a video can out-token your entire system instruction. If you control capture (mobile upload, camera frame grab), downscale to the smallest size that still answers the question.
  2. Reuse instead of re-send. Within a session, earlier turns are replayed from session history — which is exactly why large media in history hurts. Keep heavy assets out of turns you don’t need later, or summarise them into text after the answering turn.

Streaming and output on the other side

Streaming works the same way for multimodal turns: partial events arrive as the model produces text, and if you ask for modalities in the config, generated media parts arrive in the response as inline_data parts you can decode:

response = client.models.generate_content(
    model='gemini-3.8-flash',
    contents='Draw a quick architecture sketch of this service.',
    config=types.GenerateContentConfig(
        response_modalities=['TEXT', 'IMAGE'],
    ),
)

for part in response.parts or []:
    if part.inline_data:
        with open('sketch.png', 'wb') as fh:
            fh.write(part.inline_data.data)

In an ADK agent this shows up as ordinary events in the stream — the same [part.text] loop you already have, plus parts carrying inline_data that your transport layer decides to save, render, or ignore.

Failure modes worth testing before you ship

  • Wrong MIME type. A .jpg declared as image/png, or a video served as application/octet-stream, produces confusing model behaviour or a hard API error. Guess with mimetypes.guess_type, then validate.
  • Oversized inline payloads. Fail late and confusingly at request time. Enforce a size check at upload, and route big files to the Files API or GCS.
  • Silent downscaling. If your client auto-compresses images, your OCR accuracy drops without any error. Pin the resize policy yourself.
  • Mixed content ordering. Put the question next to the media in the same Content. A text part sent in a separate earlier message makes the model infer the association.
  • Safety filtering on media. Harm-category thresholds apply to multimodal inputs too; a blocked candidate looks like an empty answer. Surface the block reason rather than retrying blindly.

Takeaways

  • Multimodal input in ADK is just types.Part construction: from_text, from_bytes, from_uri, grouped into a types.Content and passed as the runner’s new_message.
  • Choose the transport deliberately — inline bytes for small one-shot media, the Files API for re-used uploads, gs:// URIs for large or repeated assets.
  • Tools can return media parts, so evidence can enter the conversation mid-turn instead of through the UI.
  • Media is tokenised: image resolution, audio seconds, and video frame rate all show up on the invoice and in your context budget.
  • Validate MIME types, size, and ordering at the edge — most multimodal “the model is dumb” bugs are transport bugs.

Further reading