#[non_exhaustive]pub enum StreamDelta {
TextDelta {
delta: String,
},
ReasoningDelta {
delta: String,
},
ToolCallDelta {
call_index: usize,
provider_call_id: Option<String>,
name_delta: Option<String>,
arguments_delta: Option<String>,
},
Usage(ModelUsage),
Done {
final_output: ModelOutput,
},
Error {
error: ModelInvokeError,
},
}Expand description
One incremental observation from a streaming provider.
Contract: Done MUST carry the fully-assembled ModelOutput (ordered
items, tool-call drafts with stable ids, usage) — deltas are advisory
observations for hosts, never the source of truth. A stream that ends
without Done is an UnknownOutcome-shaped failure at the driver.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
TextDelta
An increment of assistant text.
ReasoningDelta
An increment of reasoning/thinking text.
ToolCallDelta
An increment of one streamed tool call, identified by its position
among the model’s tool calls. A call seen here is an observation: the
calls to act on are the ones in Done, which leaves out a call the
response stopped in the middle of.
Fields
call_index: usizePosition of this call among the model’s tool-call drafts — how deltas are matched to calls.
Usage(ModelUsage)
A mid-stream token-usage observation.
Done
Terminal delta: generation ended. Carries the fully-assembled output —
the source of truth per this enum’s contract, including its
ModelStopReason.
Fields
final_output: ModelOutputThe fully-assembled ModelOutput — the authoritative result.
Error
In-stream failure observation carrying the gateway’s own
ModelInvokeError, so an error before any delta keeps its
classification and any server-requested retry delay.
Fields
error: ModelInvokeErrorThe failure the gateway produced.