Message

data class Message(val role: ChatCompletionRole, val content: MessageContent, val refusal: String? = null, val toolCalls: List<ToolCall>? = null, val name: String? = null, val toolCallId: String? = null)(source)

Represents a message in a chat conversation.

According to the OpenAI specification, the content field can be either:

  • A string for simple text messages

  • An array of ContentPart objects for multimodal messages (text, images, audio, etc.)

Author

Konstantin Pavlov

See also

Constructors

Link copied to clipboard
constructor(role: ChatCompletionRole, content: MessageContent, refusal: String? = null, toolCalls: List<ToolCall>? = null, name: String? = null, toolCallId: String? = null)

Properties

Link copied to clipboard

The content of the message as either a string or array of content parts.

Link copied to clipboard
val name: String?

Optional name of the author of this message.

Link copied to clipboard

Optional refusal message if the content was refused.

Link copied to clipboard

The role of the message sender (system, user, assistant, etc.).

Link copied to clipboard
@SerialName(value = "tool_call_id")
val toolCallId: String?

Optional ID of the tool call this message is responding to.

Link copied to clipboard
@SerialName(value = "tool_calls")
val toolCalls: List<ToolCall>?

Optional list of tool calls made in this message.