Home / Function/ async_stream() — anthropic-sdk-python Function Reference

async_stream() — anthropic-sdk-python Function Reference

Architecture documentation for the async_stream() function in text_completions_streaming.py from the anthropic-sdk-python codebase.

Entity Profile

Dependency Diagram

graph TD
  bab4aafc_8140_94f4_b293_3b53d9dac2af["async_stream()"]
  8ffeac10_981a_383f_b7d5_30faeda2740a["text_completions_streaming.py"]
  bab4aafc_8140_94f4_b293_3b53d9dac2af -->|defined in| 8ffeac10_981a_383f_b7d5_30faeda2740a
  style bab4aafc_8140_94f4_b293_3b53d9dac2af fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

examples/text_completions_streaming.py lines 29–40

async def async_stream() -> None:
    stream = await async_client.completions.create(
        prompt=f"{HUMAN_PROMPT} {question}{AI_PROMPT}",
        model="claude-sonnet-4-5-20250929",
        stream=True,
        max_tokens_to_sample=300,
    )

    async for completion in stream:
        print(completion.completion, end="", flush=True)

    print()

Subdomains

Frequently Asked Questions

What does async_stream() do?
async_stream() is a function in the anthropic-sdk-python codebase, defined in examples/text_completions_streaming.py.
Where is async_stream() defined?
async_stream() is defined in examples/text_completions_streaming.py at line 29.

Analyze Your Own Codebase

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

Try Supermodel Free