Skip to main content
Streaming delivers tokens as they’re generated, which enables responsive UIs and real-time output. Subconscious streams using whichever wire format you call: the OpenAI format emits Server-Sent Events (SSE) with ChatCompletionChunk objects, and the Anthropic Messages format emits the Anthropic event protocol (message_start, content_block_delta, message_stop).

Basic Streaming

Set stream=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 a data: line containing a JSON ChatCompletionChunk object:
The final chunk has finish_reason: "stop" and is followed by data: [DONE].

Messages

The Messages endpoint emits the Anthropic event protocol. Each SSE message has an event: type and a data: JSON payload, progressing through message_start, one or more content blocks (content_block_startcontent_block_deltacontent_block_stop), then message_delta and message_stop:
Unlike the Chat Completions format, there is no 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, include stream_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.
For Chat Completions, usage data is included in the final chunk of the stream.