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>
Sourcepub fn new(usage: U) -> StreamingCompletionResponse<U>
pub fn new(usage: U) -> StreamingCompletionResponse<U>
Create a terminal record carrying usage; the optional metadata starts
unset.
Trait Implementations§
Source§impl<U> Clone for StreamingCompletionResponse<U>where
U: Clone,
impl<U> Clone for StreamingCompletionResponse<U>where
U: Clone,
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 more