[ ABORT TO HUD ]
SEQ. 1
SEQ. 2
SEQ. 3

SSE Streaming Protocol

📨 Messages API Core20 min150 BASE XP

The Streaming Lifecycle

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:

  1. message_start: Provides the message ID and initial usage (input tokens).
  2. content_block_start: Indicates the start of a text or tool block.
  3. content_block_delta: Fires repeatedly with small chunks of text.
  4. content_block_stop: Signals the end of that specific content block.
  5. message_delta: Contains final metadata and stop reasons.
  6. 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"}}
SYNAPSE VERIFICATION
QUERY 1 // 3
Which SSE event continuously fires as Claude generates text tokens?
message_ping
content_block_delta
stream_output
text_generate
Watch: 139x Rust Speedup
SSE Streaming Protocol | Messages API Core — Claude Academy