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

sync_stream() — anthropic-sdk-python Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

examples/text_completions_streaming.py lines 15–26

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

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

    print()

Subdomains

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free