D2: Streaming Responses
Claude Certified Developer – Foundations exam practice questions · 10 flashcards
Question
How do you enable streaming?
1 / 10
Tip: Space flips the card, ← / → navigate.
Show all 10 Streaming Responses practice questions and answers
- How do you enable streaming?Set stream: true (or use the SDK's stream helper).
- Which protocol does Messages API streaming use?Server-sent events (SSE) over HTTP.
- What is the order of streaming events?message_start → content_block_start → content_block_delta(s) → content_block_stop → message_delta → message_stop.
- Which event carries the generated text pieces?content_block_delta (with text_delta, or input_json_delta for tool inputs).
- Where do you find the final stop_reason and output usage in a stream?In the message_delta event.
- Why stream responses in a chat UI?Users see text immediately, improving perceived latency.
- Why stream long or high max_tokens requests?To avoid HTTP timeouts; SDKs require streaming for requests that may take very long.
- How do tool inputs arrive while streaming?As partial JSON strings (input_json_delta) you accumulate until the block stops.
- How should a stream error mid-response be handled?Catch the error event, decide whether to retry, and don't treat the partial output as complete.
- Does streaming reduce cost?No. Token cost is the same; it improves responsiveness, not price.