pub enum Message {
System {
content: String,
},
User {
content: String,
},
UserMultimodal {
content: Vec<ContentBlock>,
},
Assistant {
content: String,
tool_calls: Vec<ToolCall>,
},
ToolResult {
tool_use_id: String,
content: String,
},
ProviderOutputItems {
protocol: String,
items: Vec<Value>,
},
}Expand description
A message in a multi-turn conversation.
The System variant exists so callers can express a first-class
system prompt inside messages: Vec<Message> without threading it
through the legacy context: Option<String> field on
GenerateRequest. Protocol handlers and local chat templates
that have a native system-role slot (OpenAI, Anthropic, Gemini,
Gemma 4, Qwen) emit it in the right place; ones that don’t can
fold it into the first user turn.
Variants§
System
A system prompt. Appears once, at the start of the conversation.
User
A user message (text only).
UserMultimodal
A user message with multimodal content (text + images + video + audio).
Fields
content: Vec<ContentBlock>Assistant
An assistant response, possibly with tool calls.
ToolResult
The result of executing a tool call.
ProviderOutputItems
Provider-specific output items that need to round-trip verbatim across turns. The OpenAI Responses API returns reasoning blobs, encrypted_content, web-search results, etc. as opaque structured items; the next request must include them in the same form to preserve provider-side state.
protocol identifies the provider format that produced the
items (currently "openai-responses"). Builder paths that
don’t recognize the protocol drop the variant — there is no
portable rendering across providers.
Trait Implementations§
Source§impl<'de> Deserialize<'de> for Message
impl<'de> Deserialize<'de> for Message
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Auto Trait Implementations§
impl Freeze for Message
impl RefUnwindSafe for Message
impl Send for Message
impl Sync for Message
impl Unpin for Message
impl UnsafeUnpin for Message
impl UnwindSafe for Message
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more