UIStreamEvent

Enum UIStreamEvent 

Source
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

§message_id: Option<String>

Unique identifier for this message.

§message_metadata: Option<Value>

Optional message metadata.

§

TextStart

Indicates the beginning of a text block.

Fields

§id: String

Unique identifier for this text block.

§provider_metadata: Option<Value>

Optional provider metadata.

§

TextDelta

Contains incremental text content for the text block.

Fields

§id: String

Identifier matching the text-start event.

§delta: String

Incremental text content.

§provider_metadata: Option<Value>

Optional provider metadata.

§

TextEnd

Indicates the end of a text block.

Fields

§id: String

Identifier matching the text-start event.

§provider_metadata: Option<Value>

Optional provider metadata.

§

ReasoningStart

Indicates the beginning of a reasoning block.

Fields

§id: String

Unique identifier for this reasoning block.

§provider_metadata: Option<Value>

Optional provider metadata.

§

ReasoningDelta

Contains incremental reasoning content.

Fields

§id: String

Identifier matching the reasoning-start event.

§delta: String

Incremental reasoning content.

§provider_metadata: Option<Value>

Optional provider metadata.

§

ReasoningEnd

Indicates the end of a reasoning block.

Fields

§id: String

Identifier matching the reasoning-start event.

§provider_metadata: Option<Value>

Optional provider metadata.

§

ToolInputStart

Indicates the beginning of tool input streaming.

Fields

§tool_call_id: String

Unique identifier for this tool call.

§tool_name: String

Name of the tool being called.

§provider_executed: Option<bool>

Whether the provider executed this tool directly.

§dynamic: Option<bool>

Whether this is a dynamic tool part.

§title: Option<String>

Optional UI title.

§

ToolInputDelta

Contains incremental chunks of tool input as it’s being generated.

Fields

§tool_call_id: String

Identifier matching the tool-input-start event.

§input_text_delta: String

Incremental tool input text.

§

ToolInputAvailable

Indicates that tool input is complete and ready for execution.

Fields

§tool_call_id: String

Identifier matching the tool-input-start event.

§tool_name: String

Name of the tool being called.

§input: Value

Complete tool input as JSON.

§provider_executed: Option<bool>

Whether the provider executed this tool directly.

§provider_metadata: Option<Value>

Optional provider metadata.

§dynamic: Option<bool>

Whether this is a dynamic tool part.

§title: Option<String>

Optional UI title.

§

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

§tool_call_id: String

Identifier matching the tool-input-start event.

§tool_name: String

Name of the tool being called.

§input: Value

Tool input payload.

§provider_executed: Option<bool>

Whether the provider executed this tool directly.

§provider_metadata: Option<Value>

Optional provider metadata.

§dynamic: Option<bool>

Whether this is a dynamic tool part.

§error_text: String

Error text.

§title: Option<String>

Optional UI title.

§

ToolApprovalRequest

Requests user approval for a tool call.

Fields

§approval_id: String

Approval request ID.

§tool_call_id: String

Tool call ID this approval applies to.

§

ToolOutputAvailable

Contains the result of tool execution.

Fields

§tool_call_id: String

Identifier matching the tool-input-start event.

§output: Value

Tool execution result as JSON.

§provider_executed: Option<bool>

Whether the provider executed this tool directly.

§dynamic: Option<bool>

Whether this is a dynamic tool part.

§preliminary: Option<bool>

Marks provisional tool output.

§

ToolOutputDenied

Indicates the tool output was denied by user approval.

Fields

§tool_call_id: String

Identifier matching the tool-input-start event.

§

ToolOutputError

Indicates tool output failed with an execution error.

Fields

§tool_call_id: String

Identifier matching the tool-input-start event.

§error_text: String

Error text.

§provider_executed: Option<bool>

Whether the provider executed this tool directly.

§dynamic: Option<bool>

Whether this is a dynamic tool part.

§

StartStep

Marks the beginning of a step.

§

FinishStep

Marks the completion of an LLM API call step.

§

SourceUrl

References an external URL.

Fields

§source_id: String

Unique identifier for this source.

§url: String

The URL being referenced.

§title: Option<String>

Optional title for the source.

§provider_metadata: Option<Value>

Optional provider metadata.

§

SourceDocument

References a document or file.

Fields

§source_id: String

Unique identifier for this source.

§media_type: String

IANA media type of the document.

§title: String

Title of the document.

§filename: Option<String>

Optional filename.

§provider_metadata: Option<Value>

Optional provider metadata.

§

File

Contains a file reference.

Fields

§url: String

URL to the file.

§media_type: String

IANA media type.

§provider_metadata: Option<Value>

Optional provider metadata.

§

Finish

Indicates message completion.

Fields

§finish_reason: Option<String>

Optional reason for finishing (stop, length, content-filter, tool-calls, error, other).

§message_metadata: Option<Value>

Optional message metadata.

§

Abort

Signals stream abortion with a reason.

Fields

§reason: Option<String>

Optional reason for the abort.

§

MessageMetadata

Emits incremental metadata updates for the active message.

Fields

§message_metadata: Value

Message metadata payload.

§

Error

Appends error messages to stream.

Fields

§error_text: String

Error text.

§

Data

Custom data event with a type prefix pattern (data-*).

Fields

§data_type: String

Custom type name (must start with “data-”).

§id: Option<String>

Optional stable data part ID.

§data: Value

Custom data payload.

§transient: Option<bool>

Whether the data should be treated as transient.

Implementations§

Source§

impl UIStreamEvent

Source

pub fn message_start(message_id: impl Into<String>) -> Self

Create a start event (message start).

Source

pub fn start() -> Self

Create a start event without message ID.

Source

pub fn text_start(id: impl Into<String>) -> Self

Create a text-start event.

Source

pub fn text_delta(id: impl Into<String>, delta: impl Into<String>) -> Self

Create a text-delta event.

Source

pub fn text_end(id: impl Into<String>) -> Self

Create a text-end event.

Source

pub fn reasoning_start(id: impl Into<String>) -> Self

Create a reasoning-start event.

Source

pub fn reasoning_delta(id: impl Into<String>, delta: impl Into<String>) -> Self

Create a reasoning-delta event.

Source

pub fn reasoning_end(id: impl Into<String>) -> Self

Create a reasoning-end event.

Source

pub fn tool_input_start( tool_call_id: impl Into<String>, tool_name: impl Into<String>, ) -> Self

Create a tool-input-start event.

Source

pub fn tool_input_delta( tool_call_id: impl Into<String>, delta: impl Into<String>, ) -> Self

Create a tool-input-delta event.

Source

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.

Source

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.

Source

pub fn tool_approval_request( approval_id: impl Into<String>, tool_call_id: impl Into<String>, ) -> Self

Create a tool-approval-request event.

Source

pub fn tool_output_available( tool_call_id: impl Into<String>, output: Value, ) -> Self

Create a tool-output-available event.

Source

pub fn tool_output_denied(tool_call_id: impl Into<String>) -> Self

Create a tool-output-denied event.

Source

pub fn tool_output_error( tool_call_id: impl Into<String>, error_text: impl Into<String>, ) -> Self

Create a tool-output-error event.

Source

pub fn start_step() -> Self

Create a start-step event.

Source

pub fn finish_step() -> Self

Create a finish-step event.

Source

pub fn source_url( source_id: impl Into<String>, url: impl Into<String>, title: Option<String>, ) -> Self

Create a source-url event.

Source

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.

Source

pub fn file(url: impl Into<String>, media_type: impl Into<String>) -> Self

Create a file event.

Source

pub fn finish() -> Self

Create a finish event.

Source

pub fn finish_with_reason(reason: impl Into<String>) -> Self

Create a finish event with a reason.

Source

pub fn abort(reason: impl Into<String>) -> Self

Create an abort event.

Source

pub fn message_metadata(message_metadata: Value) -> Self

Create a message-metadata event.

Source

pub fn error(error_text: impl Into<String>) -> Self

Create an error event.

Source

pub fn data(name: impl Into<String>, data: Value) -> Self

Create a custom data event.

Source

pub fn data_with_options( name: impl Into<String>, data: Value, id: Option<String>, transient: Option<bool>, ) -> Self

Create a custom data event with optional id/transient flags.

Trait Implementations§

Source§

impl Clone for UIStreamEvent

Source§

fn clone(&self) -> UIStreamEvent

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for UIStreamEvent

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for UIStreamEvent

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for UIStreamEvent

Source§

fn eq(&self, other: &UIStreamEvent) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Serialize for UIStreamEvent

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for UIStreamEvent

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,