pub enum UIStreamEvent {
Show 25 variants
MessageStart {
message_id: Option<String>,
message_metadata: Option<Value>,
},
TextStart {
id: String,
provider_metadata: Option<Value>,
},
TextDelta {
id: String,
delta: String,
provider_metadata: Option<Value>,
},
TextEnd {
id: String,
provider_metadata: Option<Value>,
},
ReasoningStart {
id: String,
provider_metadata: Option<Value>,
},
ReasoningDelta {
id: String,
delta: String,
provider_metadata: Option<Value>,
},
ReasoningEnd {
id: String,
provider_metadata: Option<Value>,
},
ToolInputStart {
tool_call_id: String,
tool_name: String,
provider_executed: Option<bool>,
dynamic: Option<bool>,
title: Option<String>,
},
ToolInputDelta {
tool_call_id: String,
input_text_delta: String,
},
ToolInputAvailable {
tool_call_id: String,
tool_name: String,
input: Value,
provider_executed: Option<bool>,
provider_metadata: Option<Value>,
dynamic: Option<bool>,
title: Option<String>,
},
ToolInputError {
tool_call_id: String,
tool_name: String,
input: Value,
provider_executed: Option<bool>,
provider_metadata: Option<Value>,
dynamic: Option<bool>,
error_text: String,
title: Option<String>,
},
ToolApprovalRequest {
approval_id: String,
tool_call_id: String,
},
ToolOutputAvailable {
tool_call_id: String,
output: Value,
provider_executed: Option<bool>,
dynamic: Option<bool>,
preliminary: Option<bool>,
},
ToolOutputDenied {
tool_call_id: String,
},
ToolOutputError {
tool_call_id: String,
error_text: String,
provider_executed: Option<bool>,
dynamic: Option<bool>,
},
StartStep,
FinishStep,
SourceUrl {
source_id: String,
url: String,
title: Option<String>,
provider_metadata: Option<Value>,
},
SourceDocument {
source_id: String,
media_type: String,
title: String,
filename: Option<String>,
provider_metadata: Option<Value>,
},
File {
url: String,
media_type: String,
provider_metadata: Option<Value>,
},
Finish {
finish_reason: Option<String>,
message_metadata: Option<Value>,
},
Abort {
reason: Option<String>,
},
MessageMetadata {
message_metadata: Value,
},
Error {
error_text: String,
},
Data {
data_type: String,
id: Option<String>,
data: Value,
transient: Option<bool>,
},
}Expand description
Stream event types compatible with AI SDK v6.
These events map directly to the AI SDK UI Message Stream protocol. See: https://ai-sdk.dev/docs/ai-sdk-ui/stream-protocol
Variants§
MessageStart
Indicates the beginning of a new message with metadata.
AI SDK v6 expects this as {"type":"start","messageId":"..."}.
Fields
TextStart
Indicates the beginning of a text block.
Fields
TextDelta
Contains incremental text content for the text block.
Fields
TextEnd
Indicates the end of a text block.
Fields
ReasoningStart
Indicates the beginning of a reasoning block.
Fields
ReasoningDelta
Contains incremental reasoning content.
Fields
ReasoningEnd
Indicates the end of a reasoning block.
Fields
ToolInputStart
Indicates the beginning of tool input streaming.
Fields
ToolInputDelta
Contains incremental chunks of tool input as it’s being generated.
Fields
ToolInputAvailable
Indicates that tool input is complete and ready for execution.
Fields
ToolInputError
Indicates tool input validation failed before execution.
NOTE: Not currently emitted. Reserved for future client-side tool
input validation. Backend tool input errors surface via tool-output-error.
Fields
ToolApprovalRequest
Requests user approval for a tool call.
Fields
ToolOutputAvailable
Contains the result of tool execution.
Fields
ToolOutputDenied
Indicates the tool output was denied by user approval.
ToolOutputError
Indicates tool output failed with an execution error.
Fields
StartStep
Marks the beginning of a step.
FinishStep
Marks the completion of an LLM API call step.
SourceUrl
References an external URL.
Fields
SourceDocument
References a document or file.
Fields
File
Contains a file reference.
Fields
Finish
Indicates message completion.
Fields
Abort
Signals stream abortion with a reason.
MessageMetadata
Emits incremental metadata updates for the active message.
Error
Appends error messages to stream.
Data
Custom data event with a type prefix pattern (data-*).
Implementations§
Source§impl UIStreamEvent
impl UIStreamEvent
Sourcepub fn message_start(message_id: impl Into<String>) -> Self
pub fn message_start(message_id: impl Into<String>) -> Self
Create a start event (message start).
Sourcepub fn text_start(id: impl Into<String>) -> Self
pub fn text_start(id: impl Into<String>) -> Self
Create a text-start event.
Sourcepub fn text_delta(id: impl Into<String>, delta: impl Into<String>) -> Self
pub fn text_delta(id: impl Into<String>, delta: impl Into<String>) -> Self
Create a text-delta event.
Sourcepub fn reasoning_start(id: impl Into<String>) -> Self
pub fn reasoning_start(id: impl Into<String>) -> Self
Create a reasoning-start event.
Sourcepub fn reasoning_delta(id: impl Into<String>, delta: impl Into<String>) -> Self
pub fn reasoning_delta(id: impl Into<String>, delta: impl Into<String>) -> Self
Create a reasoning-delta event.
Sourcepub fn reasoning_end(id: impl Into<String>) -> Self
pub fn reasoning_end(id: impl Into<String>) -> Self
Create a reasoning-end event.
Sourcepub fn tool_input_start(
tool_call_id: impl Into<String>,
tool_name: impl Into<String>,
) -> Self
pub fn tool_input_start( tool_call_id: impl Into<String>, tool_name: impl Into<String>, ) -> Self
Create a tool-input-start event.
Sourcepub fn tool_input_delta(
tool_call_id: impl Into<String>,
delta: impl Into<String>,
) -> Self
pub fn tool_input_delta( tool_call_id: impl Into<String>, delta: impl Into<String>, ) -> Self
Create a tool-input-delta event.
Sourcepub fn tool_input_available(
tool_call_id: impl Into<String>,
tool_name: impl Into<String>,
input: Value,
) -> Self
pub fn tool_input_available( tool_call_id: impl Into<String>, tool_name: impl Into<String>, input: Value, ) -> Self
Create a tool-input-available event.
Sourcepub fn tool_input_error(
tool_call_id: impl Into<String>,
tool_name: impl Into<String>,
input: Value,
error_text: impl Into<String>,
) -> Self
pub fn tool_input_error( tool_call_id: impl Into<String>, tool_name: impl Into<String>, input: Value, error_text: impl Into<String>, ) -> Self
Create a tool-input-error event.
Sourcepub fn tool_approval_request(
approval_id: impl Into<String>,
tool_call_id: impl Into<String>,
) -> Self
pub fn tool_approval_request( approval_id: impl Into<String>, tool_call_id: impl Into<String>, ) -> Self
Create a tool-approval-request event.
Sourcepub fn tool_output_available(
tool_call_id: impl Into<String>,
output: Value,
) -> Self
pub fn tool_output_available( tool_call_id: impl Into<String>, output: Value, ) -> Self
Create a tool-output-available event.
Sourcepub fn tool_output_denied(tool_call_id: impl Into<String>) -> Self
pub fn tool_output_denied(tool_call_id: impl Into<String>) -> Self
Create a tool-output-denied event.
Sourcepub fn tool_output_error(
tool_call_id: impl Into<String>,
error_text: impl Into<String>,
) -> Self
pub fn tool_output_error( tool_call_id: impl Into<String>, error_text: impl Into<String>, ) -> Self
Create a tool-output-error event.
Sourcepub fn start_step() -> Self
pub fn start_step() -> Self
Create a start-step event.
Sourcepub fn finish_step() -> Self
pub fn finish_step() -> Self
Create a finish-step event.
Sourcepub fn source_url(
source_id: impl Into<String>,
url: impl Into<String>,
title: Option<String>,
) -> Self
pub fn source_url( source_id: impl Into<String>, url: impl Into<String>, title: Option<String>, ) -> Self
Create a source-url event.
Sourcepub fn source_document(
source_id: impl Into<String>,
media_type: impl Into<String>,
title: impl Into<String>,
filename: Option<String>,
) -> Self
pub fn source_document( source_id: impl Into<String>, media_type: impl Into<String>, title: impl Into<String>, filename: Option<String>, ) -> Self
Create a source-document event.
Sourcepub fn file(url: impl Into<String>, media_type: impl Into<String>) -> Self
pub fn file(url: impl Into<String>, media_type: impl Into<String>) -> Self
Create a file event.
Sourcepub fn finish_with_reason(reason: impl Into<String>) -> Self
pub fn finish_with_reason(reason: impl Into<String>) -> Self
Create a finish event with a reason.
Sourcepub fn message_metadata(message_metadata: Value) -> Self
pub fn message_metadata(message_metadata: Value) -> Self
Create a message-metadata event.
Trait Implementations§
Source§impl Clone for UIStreamEvent
impl Clone for UIStreamEvent
Source§fn clone(&self) -> UIStreamEvent
fn clone(&self) -> UIStreamEvent
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more