MessagePart

sealed interface MessagePart(source)

A discrete piece of content within a Message. Parts are typed by their direction and purpose: RequestPart parts go to the LLM, ResponsePart parts come from the LLM, and ContentPart parts (text, attachments) are valid in both directions.

Inheritors

Types

Link copied to clipboard
data class Attachment @JvmOverloads constructor(val source: AttachmentSource, val cacheControl: CacheControl? = null) : MessagePart.ContentPart

Attachment content part of the message.

Link copied to clipboard

Represents a part of a message that can be used in both request and response contexts. Parts can be text MessagePart.Text or attachments MessagePart.Attachment.

Link copied to clipboard
data class Reasoning @JvmOverloads constructor(val content: List<String>, val summary: List<String>? = null, val encrypted: String? = null, val id: String? = null) : MessagePart.ResponsePart

Represents a reasoning message exchanged in a chat system, encapsulating the content, role, and associated metadata, with an optional reference to the original thinking process.

Link copied to clipboard

A part that can appear in a request sent to the LLM. All request parts carry an optional cacheControl directive.

Link copied to clipboard

A part that can appear in a response received from the LLM (e.g. text, reasoning, or tool calls).

Link copied to clipboard
data class Text @JvmOverloads constructor(val text: String, val cacheControl: CacheControl? = null) : MessagePart.ContentPart

Text content part of the message.

Link copied to clipboard
sealed interface Tool : MessagePart

Represents messages exchanged with tools, either as calls or results.