- Namespace
- ModelContextProtocol.Protocol
- Assembly
- ModelContextProtocol.Core.dll
Represents an image provided to or from an LLM.
public sealed class ImageContentBlock : ContentBlock
- Inheritance
-
ImageContentBlock
- Inherited Members
- Extension Methods
Constructors
ImageContentBlock()
public ImageContentBlock()
Properties
Data
Gets or sets the base64-encoded UTF-8 bytes representing the image data.
[JsonPropertyName("data")]
public required ReadOnlyMemory<byte> Data { get; set; }
Property Value
Remarks
DecodedData
Gets the decoded image data represented by Data.
[JsonIgnore]
public ReadOnlyMemory<byte> DecodedData { get; }
Property Value
Remarks
MimeType
Gets or sets the MIME type (or "media type") of the content, specifying the format of the data.
[JsonPropertyName("mimeType")]
public required string MimeType { get; set; }
Property Value
Remarks
Type
When overridden in a derived class, gets the type of content.
public override string Type { get; }
Property Value
- string
The type of content. Valid values include "image", "audio", "text", "resource", "resource_link", "tool_use", and "tool_result".
Remarks
Methods
FromBytes(ReadOnlyMemory<byte>, string)
public static ImageContentBlock FromBytes(ReadOnlyMemory<byte> bytes, string mimeType)
Parameters
bytesReadOnlyMemory<byte>The unencoded image bytes.
mimeTypestringThe MIME type of the image.
Returns
- ImageContentBlock
A new ImageContentBlock instance.
Remarks
Exceptions
- ArgumentNullException
mimeTypeis null.- ArgumentException
mimeTypeis empty or composed entirely of whitespace.