pub enum UIMessagePart {
Text(TextPart),
Reasoning(ReasoningPart),
File(FilePart),
Tool(ToolPart),
SourceUrl(SourceUrlPart),
SourceDocument(SourceDocumentPart),
StepStart,
Data(DataPart),
}Expand description
AI SDK UIMessage part types.
A message consists of one or more parts, each representing a different type of content (text, file, tool call, reasoning, etc.).
The format uses a type field to distinguish between different part types:
{ "type": "text", "text": "Hello" }
{ "type": "file", "mediaType": "image/png", "url": "..." }
{ "type": "tool-get_weather", "toolCallId": "...", "state": "input-available" }
{ "type": "data-usage", "data": {...} }Variants§
Text(TextPart)
Text content
Reasoning(ReasoningPart)
Reasoning/thinking content
File(FilePart)
File attachment
Tool(ToolPart)
Tool invocation (AI SDK 5.x ToolUIPart format)
SourceUrl(SourceUrlPart)
URL source
SourceDocument(SourceDocumentPart)
Document source
StepStart
Step start marker
Data(DataPart)
Dynamic data part (data-{name} pattern)
Implementations§
Source§impl UIMessagePart
impl UIMessagePart
Sourcepub fn is_reasoning(&self) -> bool
pub fn is_reasoning(&self) -> bool
Returns true if this is a Reasoning part.
Sourcepub fn as_file(&self) -> Option<(&str, &str, Option<&String>)>
pub fn as_file(&self) -> Option<(&str, &str, Option<&String>)>
Gets the file content if this is a File part.
Returns a tuple of (media_type, url, optional_filename).
Sourcepub fn state(&self) -> Option<PartState>
pub fn state(&self) -> Option<PartState>
Gets the streaming state if applicable.
Returns Some(state) for Text and Reasoning parts, None otherwise.
Sourcepub fn media_type_kind(&self) -> Option<MediaType>
pub fn media_type_kind(&self) -> Option<MediaType>
Parses the media type into a MediaType category.
Returns Some(MediaType) for File and SourceDocument parts, None otherwise.
Trait Implementations§
Source§impl Clone for UIMessagePart
impl Clone for UIMessagePart
Source§fn clone(&self) -> UIMessagePart
fn clone(&self) -> UIMessagePart
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more