Expand description
SSE (Server-Sent Events) stream parser.
Parses the text/event-stream format used by LLM APIs for streaming
responses. Yields StreamEvent values as content blocks arrive.
The stream processes these SSE event types:
message_start— initializes the response with usage datacontent_block_start— begins a new content block (text, tool_use, thinking)content_block_delta— appends partial data to the current blockcontent_block_stop— finalizes and yields the completed blockmessage_delta— final usage and stop_reasonmessage_stop— stream complete
Structs§
- Error
Payload - Message
Delta Payload - Message
Start Payload - Stream
Parser - Accumulates streaming data and produces
StreamEventvalues.
Enums§
- RawContent
Block - RawDelta
- RawSse
Event - Raw SSE data payload (deserialized from each
data:line). - Stream
Event - Events yielded by the stream parser.