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

tools_stream.py — anthropic-sdk-python Source File

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

File python AnthropicClient SyncAPI 2 imports 1 functions

Entity Profile

Dependency Diagram

graph LR
  15d8d952_51b1_ba07_c8dd_61ff69b2b598["tools_stream.py"]
  22e54b11_c61c_96dc_bf33_dfc7151750e9["asyncio"]
  15d8d952_51b1_ba07_c8dd_61ff69b2b598 --> 22e54b11_c61c_96dc_bf33_dfc7151750e9
  d10c5377_2939_0f0b_cc44_8759393f2853["anthropic"]
  15d8d952_51b1_ba07_c8dd_61ff69b2b598 --> d10c5377_2939_0f0b_cc44_8759393f2853
  style 15d8d952_51b1_ba07_c8dd_61ff69b2b598 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

import asyncio

from anthropic import AsyncAnthropic

client = AsyncAnthropic()


async def main() -> None:
    async with client.messages.stream(
        max_tokens=1024,
        model="claude-sonnet-4-5-20250929",
        tools=[
            {
                "name": "get_weather",
                "description": "Get the weather at a specific location",
                "input_schema": {
                    "type": "object",
                    "properties": {
                        "location": {"type": "string", "description": "The city and state, e.g. San Francisco, CA"},
                        "unit": {
                            "type": "string",
                            "enum": ["celsius", "fahrenheit"],
                            "description": "Unit for the output",
                        },
                    },
                    "required": ["location"],
                },
            }
        ],
        messages=[{"role": "user", "content": "What is the weather in SF?"}],
    ) as stream:
        async for event in stream:
            if event.type == "input_json":
                print(f"delta: {repr(event.partial_json)}")
                print(f"snapshot: {event.snapshot}")

    print()


asyncio.run(main())

Subdomains

Functions

Dependencies

  • anthropic
  • asyncio

Frequently Asked Questions

What does tools_stream.py do?
tools_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 tools_stream.py?
tools_stream.py defines 1 function(s): main.
What does tools_stream.py depend on?
tools_stream.py imports 2 module(s): anthropic, asyncio.
Where is tools_stream.py in the architecture?
tools_stream.py is located at examples/tools_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