Streaming events from the Python SDK are distinguished by type field (text, thinking, citation, etc.) and follow a delta-plus-snapshot pattern: a delta carries the new incremental data while snapshot holds the full accumulated state, allowing callers to consume either progressive or complete values without manual concatenation. The SDK's Raw events mirror the API's native protocol, while synthesized events like TextEvent, ThinkingEvent, and InputJsonEvent add snapshot tracking and convenience methods such as TextEvent.parsed_snapshot() for incremental JSON parsing of structured output.
All streaming event types for MessageStream and AsyncMessageStream are defined in src/anthropic/lib/streaming/_types.py and exported from anthropic.lib.streaming; the top-level union type ParsedMessageStreamEvent is what iteration yields.[1][2] The Raw prefix distinguishes the API's native protocol events (RawMessageStartEvent, RawContentBlockDeltaEvent, etc.) from the higher-level, SDK-synthesized events (TextEvent, ThinkingEvent, and their peers).[1]
TextEvent (type literal "text") carries both text — the incremental delta — and snapshot — the full accumulated text so far — giving callers access to either progressive or complete text without manual concatenation.[1][3] TextEvent.parsed_snapshot() parses snapshot as JSON using jiter.from_json with partial_mode="trailing-strings", enabling incremental JSON parsing of structured output during streaming.[1] CitationEvent (type literal "citation") follows the same delta-plus-snapshot pattern: citation holds the single new Citation, while snapshot holds the full list of all accumulated citations.[1] ThinkingEvent (type literal "thinking") carries both the incremental thinking delta and the full accumulated snapshot, supporting streaming of extended-thinking output.[1] SignatureEvent (type literal "signature") carries only the signature of a thinking block — no delta or snapshot — marking it as a terminal event for a thinking content block's signature.[1] InputJsonEvent (type literal "input_json") carries partial_json — a raw partial JSON string delta (e.g. '"San Francisco,') — and snapshot, the currently accumulated parsed object (e.g. {'location': 'San Francisco, CA'}), enabling callers to observe tool-input JSON as it streams in.[1][3]
At stream end, a message_stop event fires with a fully accumulated Message accessible as event.message.[3] A content_block_stop event fires when a full ContentBlock has been accumulated, accessible as event.content_block.[3] ParsedMessageStopEvent and ParsedContentBlockStopEvent are generic subclasses of those raw stop events that substitute ParsedMessage[ResponseFormatT] and ParsedContentBlock[ResponseFormatT] for the plain Message and ContentBlock, carrying structured-output parse results at stream end.[1]
ParsedMessageStreamEvent is the discriminated union (discriminator field: type) of TextEvent, CitationEvent, ThinkingEvent, SignatureEvent, InputJsonEvent, RawMessageStartEvent, RawMessageDeltaEvent, ParsedMessageStopEvent[ResponseFormatT], RawContentBlockStartEvent, RawContentBlockDeltaEvent, and ParsedContentBlockStopEvent[ResponseFormatT]; event-handler code branches on event.type to narrow to the concrete type — see MessageStream helpers for the handler API.[1]
Sources