OpenAIMessage

@Serializable
data class OpenAIMessage(val role: Role, val content: OpenAIChatCompletionContent? = null, val reasoningContent: String? = null, val reasoning: String? = null, val refusal: String? = null, val audio: OpenAIChatCompletionAudioResponse? = null, val functionCall: OpenAIFunctionCall? = null, val toolCalls: List<OpenAIToolCall>? = null)

OpenAI response message from a chat completion.

Example:

{
"role": "assistant",
"content": "Hello! How can I help you today?"
}

Constructors

Link copied to clipboard
constructor(role: Role, content: OpenAIChatCompletionContent? = null, reasoningContent: String? = null, reasoning: String? = null, refusal: String? = null, audio: OpenAIChatCompletionAudioResponse? = null, functionCall: OpenAIFunctionCall? = null, toolCalls: List<OpenAIToolCall>? = null)

Properties

Link copied to clipboard

Audio data when the audio output modality is requested. null when the response contains no audio.

Link copied to clipboard

The message content. null when the model only returns tool calls.

Link copied to clipboard

Returns the effective reasoning content, preferring reasoningContent over reasoning.

Link copied to clipboard
@SerialName(value = "function_call")
val functionCall: OpenAIFunctionCall?

Deprecated function call, replaced by toolCalls. null when the model did not use legacy function calling.

Link copied to clipboard

Reasoning content (legacy field). null if not present.

Link copied to clipboard
@SerialName(value = "reasoning_content")
val reasoningContent: String?

Reasoning content (primary field). null if not present.

Link copied to clipboard

The refusal message generated by the model. null if the model did not refuse the request.

Link copied to clipboard
val role: Role

The role of the message sender.

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

Tool calls requested by the model. null if none.