Two ways to stream in Python
The SDK gives you two streaming entry points. client.messages.stream(...) is a context-manager-style helper with rich convenience methods (text_stream, get_final_message, on_event). client.messages.create(stream=True) is the lower-level path that returns the raw event iterator. Use the helper for chat UI; use the iterator when you want full control over event handling.
get_final_message gives you usage
While you are streaming text, you do not have token usage yet. Usage is finalized at message_stop. The helper exposes it via stream.get_final_message() after iteration completes; the iterator path requires you to capture message_delta events and accumulate.
Persisting the stream as you go
For applications that log or replay sessions (cwkPippa), write each text delta to durable storage before rendering it to the user. JSONL append-only with explicit flush after every line means a hard kill mid-stream still leaves a complete record of what the user actually saw.