pub struct ChatMessage {
pub role: Role,
pub content: Option<Content>,
pub name: Option<String>,
pub tool_calls: Vec<ToolCall>,
pub tool_call_id: Option<String>,
pub reasoning: Option<String>,
pub reasoning_details: Vec<ReasoningDetail>,
}Expand description
A chat message (request or response).
Fields§
§role: Role§content: Option<Content>content is a plain string or an array of content parts. Optional because an
assistant message that only calls tools may omit it.
name: Option<String>§tool_calls: Vec<ToolCall>§tool_call_id: Option<String>Set when role == Tool.
reasoning: Option<String>Open reasoning text the assistant emitted (OpenRouter reasoning), if any. The flat,
human-readable form; the structured reasoning_details is the
replay-safe one.
reasoning_details: Vec<ReasoningDetail>Structured reasoning blocks (open and hidden, with signatures — see ReasoningDetail). Echo
these back verbatim on the next request to preserve signed reasoning across a turn.
Implementations§
Source§impl ChatMessage
impl ChatMessage
Sourcepub fn text(&self) -> Option<&str>
pub fn text(&self) -> Option<&str>
Accumulated plain-text content, if the message carries a text body.
Sourcepub fn reasoning_text(&self) -> Option<String>
pub fn reasoning_text(&self) -> Option<String>
The visible (open) reasoning for this message: the flat reasoning text if present, else the
concatenation of the open reasoning_details blocks. None when the turn carried no visible
reasoning (it may still carry hidden blocks — see reasoning_details).
Trait Implementations§
Source§impl Clone for ChatMessage
impl Clone for ChatMessage
Source§fn clone(&self) -> ChatMessage
fn clone(&self) -> ChatMessage
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more