AiMessage

References
public sealed class AiMessage
A single message in an AI conversation. The shape varies by role: system/user/assistant text messages carry only Text; assistant tool-call messages carry only ToolCall; tool result messages carry ToolName plus the result in Text. Construct via the static factory methods.

Properties

ReasoningContent

#
public string ReasoningContent { get; }
Chain-of-thought returned by reasoning-mode models (DeepSeek thinking models require this to be round-tripped back to the API on subsequent turns or the request is rejected). Null when the provider didn't return one. Only meaningful on assistant messages.

Role

#
public AiMessageRole Role { get; }

Text

#
public string Text { get; }
Text content for system/user/assistant text messages, or the result body for tool messages. Null for assistant tool-call messages.

ToolCall

#
public AiToolCall ToolCall { get; }
Populated only for assistant messages that are tool calls; null otherwise.

ToolName

#
public string ToolName { get; }
Populated only for tool result messages; identifies which tool the result is for.

ToolUseId

#
public string ToolUseId { get; }
Populated only for tool result messages; the provider-assigned id of the call this result responds to.

Methods

Assistant

#
public static AiMessage Assistant(string text, string reasoningContent = null)
text (string)
reasoningContent (string = null)

AssistantToolCall

#
public static AiMessage AssistantToolCall(AiToolCall call, string reasoningContent = null)
call (AiToolCall)
reasoningContent (string = null)

System

#
public static AiMessage System(string text)
text (string)

ToolResult

#
public static AiMessage ToolResult(AiToolCall call, string content)
call (AiToolCall)
content (string)

User

#
public static AiMessage User(string text)
text (string)