Content
Sealed interface hierarchy modeling all possible content in chat messages.
Content is divided into three sub-hierarchies:
Request — Content that can be sent to a model (Text, Parts, ToolCall, ToolResult).
Response — Content received from a model (Text, Parts, ToolCall, Reasoning).
StreamResponse — Content arriving in streaming chunks (Text, ToolCallDelta, Reasoning).
The concrete types are:
Text — Plain text content.
ToolCall — A tool invocation requested by the model.
ToolCallDelta — An incremental streaming tool call chunk.
ToolResult — The result of executing a tool.
Reasoning — Model reasoning/thinking content.
Parts — Multi-part content (text + images).
Samples
// Create a message with text content.
val message = Message(
role = Role.User,
content = Content.Text("Hello, how are you?")
)// Working with Content.Response:
when (contentResponse) {
is Content.Parts -> println("Parts: ${contentResponse.parts}")
is Content.Reasoning -> println("Reasoning: ${contentResponse.value}")
is Content.Text -> println("Output: ${contentResponse.text}")
is Content.ToolCall -> println("Tool call: ${contentResponse.name} with ${contentResponse.argumentsJson}")
}Inheritors
Types
Multi-part content containing a list of ContentPart items.
Model reasoning/thinking content.
Content arriving in streaming chunks.
Plain text content.
A tool invocation requested by the model.
An incremental streaming tool call chunk.
The result of executing a tool, sent back to the model.