ChatCompletionChunk objects, and the Anthropic Messages format emits the Anthropic event protocol (message_start, content_block_delta, message_stop).
Basic Streaming
Setstream=True (or use client.messages.stream(...) with the Anthropic SDK) to receive a stream of chunks instead of waiting for the full response:
SSE Format
Chat Completions
Each event in the stream is adata: line containing a JSON ChatCompletionChunk object:
finish_reason: "stop" and is followed by data: [DONE].
Messages
The Messages endpoint emits the Anthropic event protocol. Each SSE message has anevent: type and a data: JSON payload, progressing through message_start, one or more content blocks (content_block_start → content_block_delta → content_block_stop), then message_delta and message_stop:
data: [DONE] sentinel — the stream ends with message_stop.
Error Handling
Errors during streaming are delivered as SSE events. Both SDKs raise exceptions automatically:Usage Statistics
For the Chat Completions format, includestream_options to receive token usage in the final chunk. For the Messages format, usage is built in: input_tokens arrives on message_start and output_tokens on message_delta.