pub struct StreamingCompletionResponse<U = Usage> {
pub usage: U,
pub finish_reason: Option<FinishReason>,
pub response_id: Option<String>,
pub model: Option<String>,
pub provider_request_id: Option<String>,
pub logprobs: Option<Value>,
pub additional_params: Option<AdditionalParams>,
}Expand description
Final streaming response. U is the provider’s streaming usage payload
(Usage for OpenAI itself; providers with richer usage accounting, e.g.
Mistral and DeepSeek, substitute their own via
OpenAICompatibleProvider::StreamingUsage).
This is the provider-native terminal record yielded by
GenericCompletionModel::raw_stream. The normalized path maps it into a
StreamFinal exactly once, through
normalize_stream.
Fields§
§usage: UUsage reported on the stream’s terminal event.
finish_reason: Option<FinishReason>Why the model stopped generating, when the stream reported it.
Normalized out of the OpenAI-compatible finish_reason vocabulary, with
unrecognized values preserved verbatim. The Stop -> ToolCalls
upgrade is deliberately not applied here: it belongs to
normalize_stream, the only place
that sees which tool calls the stream actually emitted.
response_id: Option<String>Provider-assigned response identifier, when the stream emitted one.
model: Option<String>Provider-reported model identifier, when the stream emitted one.
provider_request_id: Option<String>The transport request id from the SSE connection’s x-request-id
response header — not part of any stream frame; stamped by the
transport. None when the provider did not report one.
logprobs: Option<Value>Token log probabilities accumulated from all primary-choice chunks.
This stays provider-native on GenericCompletionModel::raw_stream:
normalized completions do not currently model log probabilities, just
as the blocking normalized path omits Choice::logprobs while its raw
response retains them.
additional_params: Option<AdditionalParams>Provider-specific top-level fields accumulated from the stream’s
chunks, such as OpenAI’s service_tier and system_fingerprint or
OpenRouter’s routed provider.
Implementations§
Source§impl<U> StreamingCompletionResponse<U>
impl<U> StreamingCompletionResponse<U>
Trait Implementations§
Source§impl<U: Clone> Clone for StreamingCompletionResponse<U>
impl<U: Clone> Clone for StreamingCompletionResponse<U>
Source§fn clone(&self) -> StreamingCompletionResponse<U>
fn clone(&self) -> StreamingCompletionResponse<U>
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl<U: Debug> Debug for StreamingCompletionResponse<U>
impl<U: Debug> Debug for StreamingCompletionResponse<U>
Source§impl<'de, U> Deserialize<'de> for StreamingCompletionResponse<U>where
U: Deserialize<'de>,
impl<'de, U> Deserialize<'de> for StreamingCompletionResponse<U>where
U: Deserialize<'de>,
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<U> Freeze for StreamingCompletionResponse<U>where
U: Freeze,
impl<U> RefUnwindSafe for StreamingCompletionResponse<U>where
U: RefUnwindSafe,
impl<U> Send for StreamingCompletionResponse<U>where
U: Send,
impl<U> Sync for StreamingCompletionResponse<U>where
U: Sync,
impl<U> Unpin for StreamingCompletionResponse<U>where
U: Unpin,
impl<U> UnsafeUnpin for StreamingCompletionResponse<U>where
U: UnsafeUnpin,
impl<U> UnwindSafe for StreamingCompletionResponse<U>where
U: UnwindSafe,
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
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> 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