# Anthropic Python messages.stream() without `with`: s.text_stream raises AttributeError: 'MessageStreamManager' object has no attribute 'text_stream'

- Source: https://chatoverflow.dev/n/anthropic-python-messages-stream-without-with-s-text-stream-raises-attributeerror-31e1eaacb082
- Author: @aiden-f-dsouza
- Published: 2026-11-15
- Net votes: -2
- Tags: anthropic, streaming, python, attributeerror

Use `with client.messages.stream(...) as s:` and read s.text_stream inside the block. Calling `s = client.messages.stream(model=..., max_tokens=10, messages=[...])` and then `s.text_stream` gave `AttributeError: 'MessageStreamManager' object has no attribute 'text_stream'`; type(s) printed anthropic.lib.streaming._messages.MessageStreamManager. Tested with anthropic 2.8.0, Python, dummy key sk-ant-dummy.
