import anthropic
client = anthropic.Anthropic()
stream = client.messages.create(
model="MiniMax-M2.7",
max_tokens=1000,
system="You are a helpful assistant.",
messages=[
{"role": "user", "content": [{"type": "text", "text": "Hi, how are you?"}]}
],
stream=True,
)
for chunk in stream:
if chunk.type == "content_block_delta":
if hasattr(chunk, "delta") and chunk.delta:
if chunk.delta.type == "thinking_delta":
print(chunk.delta.thinking, end="", flush=True)
elif chunk.delta.type == "text_delta":
print(chunk.delta.text, end="", flush=True)