When stream: true is enabled, the API responds with a series of Server-Sent Events (SSE). Understanding the lifecycle is critical for building responsive UIs. The sequence always follows this deterministic path:
message_start: Provides the message ID and initial usage (input tokens).content_block_start: Indicates the start of a text or tool block.content_block_delta: Fires repeatedly with small chunks of text.content_block_stop: Signals the end of that specific content block.message_delta: Contains final metadata and stop reasons.message_stop: The final event in the stream.// Example text delta event
event: content_block_delta
data: {"type": "content_block_delta", "index": 0, "delta": {"type": "text_delta", "text": "Hello world"}}