Table of Contents

Class LiteRtAttachment

Namespace
LiteRtLmSharp
Assembly
LiteRtLmSharp.dll

One image or audio attachment to add to a user message on a multimodal model. Attach it to a turn with Send(string, IReadOnlyList<LiteRtAttachment>?, LiteRtSendOptions?) (or the streaming overload). The engine must have been loaded with the matching modality enabled (VisionBackend for images, AudioBackend for audio) and the model must support it (e.g. the Gemma 4 E-series handle both).

Two carriers, both mapping to the LiteRT-LM content-part wire format ({"type":"image"|"audio", …}): inline LiteRtLmSharp.LiteRtAttachment.Bytes (sent as a base64 "blob"), or a LiteRtLmSharp.LiteRtAttachment.Path on disk (sent as "path" and memory-mapped natively, avoiding a base64 round-trip — desktop only; the path must be readable by the native process).

public sealed class LiteRtAttachment
Inheritance
LiteRtAttachment
Inherited Members

Properties

Kind

Whether this is an image or an audio attachment.

public LiteRtAttachmentKind Kind { get; }

Property Value

LiteRtAttachmentKind

Methods

Audio(ReadOnlySpan<byte>)

An audio clip from in-memory bytes (WAV/…); sent as a base64 blob. The bytes are copied, so the caller may reuse the buffer.

public static LiteRtAttachment Audio(ReadOnlySpan<byte> bytes)

Parameters

bytes ReadOnlySpan<byte>

Returns

LiteRtAttachment

Exceptions

ArgumentException

bytes is empty (the engine fails on an empty blob at send time with a far less helpful error).

AudioFile(string)

An audio clip read from a file on disk; sent as a native-memory-mapped path (no base64). Desktop only — the path must be readable by the native process.

public static LiteRtAttachment AudioFile(string path)

Parameters

path string

Returns

LiteRtAttachment

Image(ReadOnlySpan<byte>)

An image from in-memory bytes (PNG/JPEG/…); sent as a base64 blob. The bytes are copied, so the caller may reuse the buffer.

public static LiteRtAttachment Image(ReadOnlySpan<byte> bytes)

Parameters

bytes ReadOnlySpan<byte>

Returns

LiteRtAttachment

Exceptions

ArgumentException

bytes is empty (the engine fails on an empty blob at send time with a far less helpful error).

ImageFile(string)

An image read from a file on disk; sent as a native-memory-mapped path (no base64). Desktop only — the path must be readable by the native process.

public static LiteRtAttachment ImageFile(string path)

Parameters

path string

Returns

LiteRtAttachment