main() — anthropic-sdk-python Function Reference
Architecture documentation for the main() function in tools_stream.py from the anthropic-sdk-python codebase.
Entity Profile
Dependency Diagram
graph TD 18c2c024_e574_d86b_6c11_f3a20ab51804["main()"] 15d8d952_51b1_ba07_c8dd_61ff69b2b598["tools_stream.py"] 18c2c024_e574_d86b_6c11_f3a20ab51804 -->|defined in| 15d8d952_51b1_ba07_c8dd_61ff69b2b598 style 18c2c024_e574_d86b_6c11_f3a20ab51804 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
examples/tools_stream.py lines 8–37
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()
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does main() do?
main() is a function in the anthropic-sdk-python codebase, defined in examples/tools_stream.py.
Where is main() defined?
main() is defined in examples/tools_stream.py at line 8.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free