Expand description
SSE Streaming Parser for the Claude Messages API
The Claude API sends Server-Sent Events (SSE) when stream: true.
Format: event: <name>\ndata: <json>\n\n
This module provides:
SseParser: reads raw bytes from reqwest and yields typedStreamEventsMessageAccumulator: builds a completeMessagesResponsefrom events
The tricky part: bytes arrive in arbitrary chunks that may split mid-line.
We buffer until we see \n\n (end of SSE event), then parse.
Structs§
- Message
Accumulator - Accumulates streaming events into a complete
MessagesResponse. - Message
Delta Payload - Top-level message metadata update
- SseParser
- Parses SSE events from a reqwest byte stream.
Enums§
- Content
Delta - Incremental content within a
content_block_deltaevent - Stream
Event - All possible SSE event types from the Claude streaming API.
Each variant matches an
event: <name>line in the SSE stream.