ag2-multimodal-input
Skill252 starsChanged 6 months agoApache-2.0View on GitHub
Send images, audio, video, or documents into an AG2 beta `Agent` alongside text. Pass `ImageInput`, `AudioInput`, `VideoInput`, or `DocumentInput` as positional args to `agent.ask(...)`. Use when the user wants the agent to process non-text input — describe a photo, transcribe audio, summarise a PDF, analyse a video. Covers per-provider support matrix, the four ways to source data (URL / path / bytes / file_id), Gemini-specific YouTube + media-resolution + clipping, OpenAI image-detail, Anthropic prompt-caching on attachments, and `FilesAPI` for upload lifecycle.
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 78
Gemini has the broadest multimodal support: If you don't know which provider to pick for a multimodal task, start there.
≈ “Common” is an estimate: at least 1 in 5 of the 308,232 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Multimodal inputs
When to use
The user wants the agent to process non-text input: an image to describe, audio to transcribe, video to summarise, or a PDF / document to extract from. The same factory pattern works across providers; per-provider support varies.
60-second recipe
from autogen.beta import Agent
from autogen.beta.config import GeminiConfig
from autogen.beta.events import ImageInput
agent = Agent(
"vision",
"You describe images.",
config=GeminiConfig(model="gemini-3-flash-preview"),
)
image = ImageInput("https://example.com/photo.jpg")
reply = await agent.ask("Describe this image in detail.", image)
print(reply.body)Multiple inputs in one ask are fine:
reply = await agent.ask(
"Compare these two images.",
ImageInput("https://example.com/before.jpg"),
ImageInput("https://example.com/after.jpg"),
)Input factories
| Factory | Formats |
ImageInput(...) | JPEG, PNG, GIF, WebP |
AudioInput(...) | WAV, MP3, OGG, FLAC, AAC |
VideoInput(...) | MP4, WebM, MOV, MKV, MPEG |
DocumentInput(...) | PDF, TXT, HTML, Markdown, CSV, JSON, Office formats |
Each accepts the same four data sources:
from autogen.beta.events import ImageInput
ImageInput("https://example.com/photo.jpg") # URL
ImageInput(path="photo.jpg") # local file
ImageInput(data=raw_bytes, media_type="image/png") # bytes
ImageInput(file_id="file-abc123") # provider-uploadedProvider matrix
| Input type | OpenAI | OpenAI Responses | Gemini | Anthropic |
| Text | ✓ | ✓ | ✓ | ✓ |
| Image (URL) | ✓ | ✓ | ✓ | ✓ |
| Image (binary) | ✓ | ✓ | ✓ | ✓ |
| Audio (URL) | – | – | ✓ | – |
| Audio (binary) | ✓ | – | ✓ | – |
| Video (URL) | – | – | ✓ | – |
| Video (binary) | – | – | ✓ | – |
| Document (URL) | – | ✓ | ✓ | ✓ |
| Document (binary) | – | – | ✓ | ✓ |
| File ID | – | ✓ | – | ✓ |
Unsupported combinations raise UnsupportedInputError with a clear message.
Gemini has the broadest multimodal support. If you don't know which provider to pick for a multimodal task, start there.
Provider-specific niceties
Gemini — YouTube URLs work directly
from autogen.beta.events import VideoInput
video = VideoInput("https://www.youtube.com/watch?v=dQw4w9WgXcQ")
reply = await agent.ask("Summarize this video.", video)Gemini — large files (> 20MB) via Google Files API
from google import genai
from autogen.beta.events import VideoInput
import time
client = genai.Client()
uploaded = client.files.upload(file="large_video.mp4")
while uploaded.state.name == "PROCESSING":
time.sleep(2)
uploaded = client.files.get(name=uploaded.name)
video = VideoInput(uploaded.uri)Gemini — vendor_metadata
| Key | Purpose |
media_resolution | MEDIA_RESOLUTION_LOW/MEDIUM/HIGH/ULTRA_HIGH — token vs cost |
video_metadata | Clipping (start_offset, end_offset) and fps |
display_name | Display name for the file |
ImageInput(data=raw, media_type="image/jpeg", vendor_metadata={"media_resolution": "MEDIA_RESOLUTION_LOW"})
VideoInput(path="lecture.mp4", vendor_metadata={
"video_metadata": {"start_offset": "60s", "end_offset": "120s", "fps": 0.5},
})OpenAI — image detail
ImageInput(data=raw, media_type="image/png", vendor_metadata={"detail": "low"}) # "low" | "high" | "auto"Anthropic — File ID + prompt caching
import anthropic
from autogen.beta.events import ImageInput, DocumentInput
client = anthropic.Anthropic()
uploaded = client.beta.files.upload(file=("photo.jpg", open("photo.jpg", "rb"), "image/jpeg"))
# filename determines block type (image vs document)
image = ImageInput(file_id=uploaded.id, filename="photo.jpg")
# Cache an attachment so subsequent turns skip re-uploading
doc = DocumentInput(path="report.pdf", vendor_metadata={"cache_control": {"type": "ephemeral"}})FilesAPI — upload lifecycle, provider-agnostic
For any provider that has a file API (OpenAIConfig, OpenAIResponsesConfig, AnthropicConfig, GeminiConfig):
from autogen.beta import FilesAPI
from autogen.beta.config import OpenAIResponsesConfig
files = FilesAPI(OpenAIResponsesConfig(model="gpt-5-mini"))
uploaded = await files.upload(path="report.pdf", purpose="assistants")
print(uploaded.file_id)
# Or from bytes (filename required)
uploaded = await files.upload(data=b"...", filename="hello.txt", purpose="assistants")
# List, read, delete
all_files = await files.list()
data = await files.read(uploaded.file_id) # NotImplementedError on Gemini
await files.delete(uploaded.file_id)Pass the file_id to DocumentInput, ImageInput, etc.:
from autogen.beta.events import DocumentInput
doc = DocumentInput(file_id=uploaded.file_id)
reply = await agent.ask("Summarize this report.", doc)Going deeper
website/docs/beta/inputs/inputs.mdx— full provider matrix andvendor_metadatareference.website/docs/beta/advanced/files.mdx—FilesAPIreference (upload / list / read / delete).- For tools that return images / binary back to the LLM, see
ag2-add-custom-tool(ImageInput,BinaryInput,ToolResult).
Common pitfalls
- Picking a provider that doesn't support your input type — silently you'll get
UnsupportedInputError. Check the matrix; Gemini is broadest. FilesAPI.read()on Gemini — raisesNotImplementedError. Gemini doesn't expose download.- Calling
files.upload(data=...)withoutfilename=— raisesValueError. Filename is required for in-memory uploads. - Providing
path=anddata=to the same factory — pick one source. Same forfile_id=. - Anthropic
ImageInput(file_id=...)withoutfilename=— Anthropic decides block type (image vs document) by filename extension. Pass it. - Gemini
vendor_metadatakeys are nested —video_metadataitself takes a dict. Check the doc table for shape. - Forgetting to wait for Gemini file processing — large uploads have a
PROCESSINGstate. Pollclient.files.get(name=...)until ready before referencing the URI.
In this repository15 other files it gives its agents.
- ag2-add-custom-toolSkill
- ag2-ag-uiSkill
- ag2-hitlSkill
- ag2-knowledge-and-memorySkill
- ag2-middlewareSkill
- ag2-observers-and-alertsSkill
- ag2-overviewSkill
- ag2-quickstartSkill
- ag2-shell-toolSkill
- ag2-structured-outputSkill
- ag2-subagent-delegationSkill
- ag2-telemetrySkill
- ag2-testingSkill
- ag2-use-builtin-toolsSkill
- calculatorSkill
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

