pub enum ProviderChunk {
MessageStart {
id: String,
model: String,
},
TextDelta {
text: String,
},
ThinkingDelta {
text: String,
},
ThinkingSignature {
signature: String,
},
ToolUseStart {
id: String,
name: String,
},
ToolUseArgsDelta {
id: String,
fragment: String,
},
ToolUseEnd {
id: String,
},
Stop {
reason: StopReason,
},
Usage(Usage),
}Expand description
A single event produced by a provider’s streaming generation.
Semantic constraints:
- The first event of a stream is always
ProviderChunk::MessageStart ProviderChunk::Stopis the last semantic event; onlyProviderChunk::Usagemay appear after itProviderChunk::ToolUseArgsDeltachunks with the sametool_use_idare concatenated in arrival order to form the complete argument JSON; concurrent tool uses are accumulated per id, independent of wire orderProviderChunk::Usagemay arrive multiple times; callers should accumulate each field
Variants§
MessageStart
First event of the stream, containing only session-level metadata.
TextDelta
Incremental assistant text.
ThinkingDelta
Thinking-chain text delta (unified abstraction for Anthropic extended thinking,
DeepSeek reasoning_content, o1-style reasoning, etc.).
ThinkingSignature
Thinking chain signature (Anthropic verification data for preserving thinking
across multiple turns).
Not text; should not be merged with ProviderChunk::ThinkingDelta.
ToolUseStart
Tool call start: declares a new tool_use; subsequent
ProviderChunk::ToolUseArgsDelta and ProviderChunk::ToolUseEnd
are linked to this call via id.
ToolUseArgsDelta
A fragment of tool-use arguments.
fragment is a raw byte slice; it is not guaranteed to be a valid JSON
substring. Callers must wait until the corresponding
ProviderChunk::ToolUseEnd is received before parsing the complete payload as
JSON.
ToolUseEnd
Tool call end: all ArgsDelta for this id have been sent.
Stop
The generation has ended.
Fields
reason: StopReasonUsage(Usage)
Token usage statistics. May arrive multiple times in a single stream; callers should accumulate rather than overwrite.
Trait Implementations§
Source§impl Clone for ProviderChunk
impl Clone for ProviderChunk
Source§fn clone(&self) -> ProviderChunk
fn clone(&self) -> ProviderChunk
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for ProviderChunk
impl Debug for ProviderChunk
Source§impl<'de> Deserialize<'de> for ProviderChunk
impl<'de> Deserialize<'de> for ProviderChunk
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>,
impl Eq for ProviderChunk
Source§impl PartialEq for ProviderChunk
impl PartialEq for ProviderChunk
Source§fn eq(&self, other: &ProviderChunk) -> bool
fn eq(&self, other: &ProviderChunk) -> bool
self and other values to be equal, and is used by ==.