Rendered Source Note

Anthropic Messages API — Streaming

Generated HTML view. Markdown remains canonical.

Anthropic Messages API — Streaming

Type: official-doc Tier: 1 (Official Doc) Author(s): Anthropic Date: Accessed 2026-06-01 URL: https://platform.claude.com/docs/en/docs/build-with-claude/streaming Accessed: 2026-06-01

Why This Source Matters

Defines how a response is delivered token-by-token instead of all at once. Streaming is what makes a chatbot feel responsive: the user sees text appear immediately rather than waiting for the full completion. This source gives the exact event protocol so the learner understands what is actually arriving over the wire, not just what the SDK abstracts away.

Key Claims

Enabling streaming

Event flow (in order)

  1. message_start — a Message object with empty content.
  2. For each content block: a content_block_start, one or more content_block_delta events, then a content_block_stop. Each block has an index matching its position in the final content array.
  3. One or more message_delta events — top-level changes to the final Message (e.g. stop_reason, final usage).
  4. A final message_stop.

Content block delta types

`` event: content_block_delta data: {"type":"content_block_delta","index":0,"delta":{"type":"text_delta","text":"ello frien"}} ``

SDK usage (Python)

The official SDK abstracts the SSE parsing:

import anthropic

client = anthropic.Anthropic()

with client.messages.stream(
    max_tokens=1024,
    messages=[{"role": "user", "content": "Hello"}],
    model="claude-opus-4-8",
) as stream:
    for text in stream.text_stream:
        print(text, end="", flush=True)

Relevant To

Notes