Home / File/ thinking_stream.py — anthropic-sdk-python Source File

thinking_stream.py — anthropic-sdk-python Source File

Architecture documentation for thinking_stream.py, a python file in the anthropic-sdk-python codebase. 1 imports, 0 dependents.

File python AnthropicClient SyncAPI 1 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  42bbcd31_8f6d_2f63_8151_c7757c0f606e["thinking_stream.py"]
  d10c5377_2939_0f0b_cc44_8759393f2853["anthropic"]
  42bbcd31_8f6d_2f63_8151_c7757c0f606e --> d10c5377_2939_0f0b_cc44_8759393f2853
  style 42bbcd31_8f6d_2f63_8151_c7757c0f606e fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import anthropic

client = anthropic.Anthropic()

with client.messages.stream(
    model="claude-sonnet-4-5-20250929",
    max_tokens=3200,
    thinking={"type": "enabled", "budget_tokens": 1600},
    messages=[{"role": "user", "content": "Create a haiku about Anthropic."}],
) as stream:
    thinking = "not-started"

    for event in stream:
        if event.type == "thinking":
            if thinking == "not-started":
                print("Thinking:\n---------")
                thinking = "started"

            print(event.thinking, end="", flush=True)
        elif event.type == "text":
            if thinking != "finished":
                print("\n\nText:\n-----")
                thinking = "finished"

            print(event.text, end="", flush=True)

Subdomains

Functions

Dependencies

  • anthropic

Frequently Asked Questions

What does thinking_stream.py do?
thinking_stream.py is a source file in the anthropic-sdk-python codebase, written in python. It belongs to the AnthropicClient domain, SyncAPI subdomain.
What functions are defined in thinking_stream.py?
thinking_stream.py defines 1 function(s): thinking.
What does thinking_stream.py depend on?
thinking_stream.py imports 1 module(s): anthropic.
Where is thinking_stream.py in the architecture?
thinking_stream.py is located at examples/thinking_stream.py (domain: AnthropicClient, subdomain: SyncAPI, directory: examples).

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free