Skip to main content

Multimodal Inputs

AGUIUserMessage.Content accepts either plain text or an ordered array of multimodal content parts through the AGUIContent union.

User Message Content

The AG-UI wire model for user messages is content: string | InputContent[]. In .NET, that is represented by AGUIContent.
AGUIContent has implicit conversions from string, List<AGUIInputContent>, and AGUIInputContent[], supports collection expressions, and implements IReadOnlyList<AGUIInputContent> for normalized reads. When the stored value is a string, the read-only list facade exposes it as a single AGUITextInputContent.

Input Content Types

All content parts derive from AGUIInputContent and use the JSON type discriminator.

Text

Media Parts

Images, audio, video, and documents all derive from AGUIMediaInputContent.
When a server adapts an AG-UI request to Microsoft.Extensions.AI, AGUIChatMessageExtensions.AsChatMessages() maps data sources to DataContent, URL sources to UriContent and file sources to HostedFileContent (the handle becomes FileId; Provider has no counterpart there and is dropped on that hop, though it round-trips through JSON and protobuf). The source MIME type is preserved; when a URL source omits mimeType, UriContent infers it from the URL. If the URL does not have a recognized extension, the canonical discriminator supplies image/*, audio/*, or video/* so the modality is not lost. The complete metadata value is preserved under the MEAI content’s AdditionalProperties["metadata"] key, including object-shaped values. For inline data, a string metadata.filename property is also assigned to DataContent.Name so file-capable providers receive the filename. In the client direction, AsAGUIMessages(jsonSerializerOptions) maps DataContent and UriContent to canonical media parts based on their MIME type and serializes their AdditionalProperties as the part’s metadata. DataContent.Name is included as metadata.filename when that property is not already present.

Binary

AGUIBinaryInputContent represents an arbitrary binary input part.

Source Types

Media input parts use AGUIInputContentSource, a discriminator-based hierarchy with JSON field type.

Data Source

Use AGUIInputContentDataSource for inline base64 payloads. mimeType is required.

URL Source

Use AGUIInputContentUrlSource for HTTP(S) URLs or data URLs. mimeType is optional.

File Source

Use AGUIInputContentFileSource for bytes that already live at the model provider — an OpenAI or Anthropic file id, a Gemini file URI. Nothing is fetched and Value is opaque: hand it to the provider that issued it, or drop the part. provider and mimeType are optional.

Common Use Cases

Visual QA

Audio Transcription

Mixed Media Comparison

Use plain string Content for simple text-only turns. Use multimodal parts when order matters or when the user message includes media alongside text.