Skip to main content

ResponseStreamEvent

Enum ResponseStreamEvent 

Source
pub enum ResponseStreamEvent {
Show 22 variants ResponseCreated { sequence_number: Option<u64>, response: Response, }, ResponseInProgress { sequence_number: Option<u64>, response: Response, }, ResponseCompleted { sequence_number: Option<u64>, response: Response, }, ResponseIncomplete { sequence_number: Option<u64>, response: Response, }, ResponseFailed { sequence_number: Option<u64>, response: Response, }, Error { sequence_number: Option<u64>, message: Option<String>, code: Option<String>, param: Option<String>, }, OutputItemAdded { sequence_number: Option<u64>, output_index: Option<u32>, item: ResponseOutputItem, }, OutputItemDone { sequence_number: Option<u64>, output_index: Option<u32>, item: ResponseOutputItem, }, ContentPartAdded { sequence_number: Option<u64>, item_id: Option<String>, output_index: Option<u32>, content_index: Option<u32>, part: EventContentPart, }, ContentPartDone { sequence_number: Option<u64>, item_id: Option<String>, output_index: Option<u32>, content_index: Option<u32>, part: EventContentPart, }, OutputTextDelta { sequence_number: Option<u64>, item_id: Option<String>, output_index: Option<u32>, content_index: Option<u32>, delta: String, }, OutputTextDone { sequence_number: Option<u64>, item_id: Option<String>, output_index: Option<u32>, content_index: Option<u32>, text: String, }, ReasoningTextDelta { sequence_number: Option<u64>, item_id: Option<String>, output_index: Option<u32>, content_index: Option<u32>, delta: String, }, ReasoningTextDone { sequence_number: Option<u64>, item_id: Option<String>, output_index: Option<u32>, content_index: Option<u32>, text: String, }, FunctionCallArgumentsDelta { sequence_number: Option<u64>, item_id: Option<String>, output_index: Option<u32>, delta: String, }, FunctionCallArgumentsDone { sequence_number: Option<u64>, item_id: Option<String>, output_index: Option<u32>, arguments: String, }, CustomToolCallInputDelta { sequence_number: Option<u64>, item_id: Option<String>, output_index: Option<u32>, delta: String, }, CustomToolCallInputDone { sequence_number: Option<u64>, item_id: Option<String>, output_index: Option<u32>, input: String, }, WebSearchCallInProgress { sequence_number: Option<u64>, item_id: Option<String>, output_index: Option<u32>, }, WebSearchCallSearching { sequence_number: Option<u64>, item_id: Option<String>, output_index: Option<u32>, }, WebSearchCallCompleted { sequence_number: Option<u64>, item_id: Option<String>, output_index: Option<u32>, }, Other,
}
Expand description

One event of a streamed Responses API call.

Use Self::final_response to extract the finished Response from the terminal response.completed / response.incomplete / response.failed events.

Variants§

§

ResponseCreated

First event: the response was created, status in_progress.

Fields

§sequence_number: Option<u64>
§response: Response
§

ResponseInProgress

The response is being generated.

Fields

§sequence_number: Option<u64>
§response: Response
§

ResponseCompleted

The response completed normally; final event with the full response object including usage.

Fields

§sequence_number: Option<u64>
§response: Response
§

ResponseIncomplete

The response was truncated (e.g. max_output_tokens reached); final event with the full response object.

Fields

§sequence_number: Option<u64>
§response: Response
§

ResponseFailed

The response failed; final event with the full response object including the error details.

Fields

§sequence_number: Option<u64>
§response: Response
§

Error

An error event emitted mid-stream.

Fields

§sequence_number: Option<u64>
§message: Option<String>

A human-readable description of the error.

§code: Option<String>

The machine-readable error code.

§param: Option<String>

The request parameter that caused the error, if any.

§

OutputItemAdded

An output item (reasoning, message, tool call, …) started.

Fields

§sequence_number: Option<u64>
§output_index: Option<u32>

The index of the item in the output array.

§item: ResponseOutputItem

The item that was added.

§

OutputItemDone

An output item completed.

Fields

§sequence_number: Option<u64>
§output_index: Option<u32>
§item: ResponseOutputItem

The completed item.

§

ContentPartAdded

A content part started within an output item.

Fields

§sequence_number: Option<u64>
§item_id: Option<String>

The ID of the item the content part belongs to.

§output_index: Option<u32>
§content_index: Option<u32>

The index of the content part within the item.

§part: EventContentPart

The content part that was added.

§

ContentPartDone

A content part completed.

Fields

§sequence_number: Option<u64>
§item_id: Option<String>
§output_index: Option<u32>
§content_index: Option<u32>
§part: EventContentPart

The completed content part.

§

OutputTextDelta

An incremental text delta of an output message.

Fields

§sequence_number: Option<u64>
§item_id: Option<String>
§output_index: Option<u32>
§content_index: Option<u32>
§delta: String

The incremental text.

§

OutputTextDone

The full output text of a message content part.

Fields

§sequence_number: Option<u64>
§item_id: Option<String>
§output_index: Option<u32>
§content_index: Option<u32>
§text: String

The complete text.

§

ReasoningTextDelta

An incremental reasoning (chain-of-thought) text delta.

Fields

§sequence_number: Option<u64>
§item_id: Option<String>
§output_index: Option<u32>
§content_index: Option<u32>
§delta: String

The incremental reasoning text.

§

ReasoningTextDone

The full reasoning (chain-of-thought) text of a reasoning item.

Fields

§sequence_number: Option<u64>
§item_id: Option<String>
§output_index: Option<u32>
§content_index: Option<u32>
§text: String

The complete reasoning text.

§

FunctionCallArgumentsDelta

An incremental delta of function call arguments.

Fields

§sequence_number: Option<u64>
§item_id: Option<String>
§output_index: Option<u32>
§delta: String

The incremental arguments JSON fragment.

§

FunctionCallArgumentsDone

The full arguments of a function call.

Fields

§sequence_number: Option<u64>
§item_id: Option<String>
§output_index: Option<u32>
§arguments: String

The complete arguments JSON string.

§

CustomToolCallInputDelta

An incremental delta of custom tool call input (e.g. the apply_patch tool).

Fields

§sequence_number: Option<u64>
§item_id: Option<String>
§output_index: Option<u32>
§delta: String

The incremental input fragment.

§

CustomToolCallInputDone

The full input of a custom tool call.

Fields

§sequence_number: Option<u64>
§item_id: Option<String>
§output_index: Option<u32>
§input: String

The complete input.

§

WebSearchCallInProgress

A server-side web search started.

Fields

§sequence_number: Option<u64>
§item_id: Option<String>
§output_index: Option<u32>
§

WebSearchCallSearching

A server-side web search is searching.

Fields

§sequence_number: Option<u64>
§item_id: Option<String>
§output_index: Option<u32>
§

WebSearchCallCompleted

A server-side web search completed.

Fields

§sequence_number: Option<u64>
§item_id: Option<String>
§output_index: Option<u32>
§

Other

Any event type not covered by the variants above.

Implementations§

Source§

impl ResponseStreamEvent

Source

pub fn final_response(&self) -> Option<&Response>

Returns the final response object if this is one of the terminal events (response.completed, response.incomplete, response.failed).

Trait Implementations§

Source§

impl Clone for ResponseStreamEvent

Source§

fn clone(&self) -> ResponseStreamEvent

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for ResponseStreamEvent

Source§

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

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

impl<'de> Deserialize<'de> for ResponseStreamEvent

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 FromStr for ResponseStreamEvent

Source§

type Err = OapiError

The associated error which can be returned from parsing.
Source§

fn from_str(content: &str) -> Result<Self, Self::Err>

Parses a string s to return a value of this type. Read more

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> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

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

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

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.

Source§

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

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + 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
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + 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 = !

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

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ

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