pub struct Message {
pub role: Role,
pub content: String,
pub reasoning: Option<String>,
pub reasoning_details: ReasoningDetails,
pub tool_calls: Option<Vec<ToolCall>>,
pub tool_call_id: Option<String>,
pub parts: Option<Vec<ContentPart>>,
pub timestamp: DateTime<Utc>,
}Expand description
A single message in the LLM API request / response payload.
For tool results set tool_call_id in addition to content (which holds the tool’s output).
Fields§
§role: RoleMessage role (system, user, assistant, developer, tool).
content: StringText content of the message.
reasoning: Option<String>Reasoning retained for providers that require it on later tool turns.
reasoning_details: ReasoningDetailsComplete provider reasoning blocks for replay on subsequent tool turns.
tool_calls: Option<Vec<ToolCall>>Tool calls requested by the assistant (only on assistant messages).
tool_call_id: Option<String>ID of the tool call this is a result for (only on tool messages).
parts: Option<Vec<ContentPart>>Multimodal content parts (images, documents, audio). When present, content is also included as a text part.
timestamp: DateTime<Utc>Timestamp when the message was created.
Implementations§
Source§impl Message
impl Message
Sourcepub fn assistant(content: impl Into<String>) -> Self
pub fn assistant(content: impl Into<String>) -> Self
Create an assistant text message (no tool calls).
Sourcepub fn assistant_with_tool_calls(
content: impl Into<String>,
tool_calls: Vec<ToolCall>,
) -> Self
pub fn assistant_with_tool_calls( content: impl Into<String>, tool_calls: Vec<ToolCall>, ) -> Self
Create an assistant message that includes tool call requests.
Sourcepub fn developer(content: impl Into<String>) -> Self
pub fn developer(content: impl Into<String>) -> Self
Create a developer message (system-level instructions using the developer role).
Sourcepub fn tool_result(
tool_call_id: impl Into<String>,
content: impl Into<String>,
) -> Self
pub fn tool_result( tool_call_id: impl Into<String>, content: impl Into<String>, ) -> Self
Create a tool-result message linked to a prior ToolCall.id.
Sourcepub fn user_with_parts(
content: impl Into<String>,
parts: Vec<ContentPart>,
) -> Self
pub fn user_with_parts( content: impl Into<String>, parts: Vec<ContentPart>, ) -> Self
Create a multimodal user message with inline attachments.
Sourcepub fn strip_binary_data(&self) -> Self
pub fn strip_binary_data(&self) -> Self
Replace binary content parts (image, document, video, audio) with text placeholders so the message can be sent to models that don’t support those modalities.
Example:
Image { media_type: "image/jpeg", .. }→Text { text: "[Image: image/jpeg]" }