MCPcopy Create free account
hub / github.com/anthropics/anthropic-sdk-python / async_stream

Function async_stream

examples/text_completions_streaming.py:29–40  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

27
28
29async def async_stream() -> None:
30 stream = await async_client.completions.create(
31 prompt=f"{HUMAN_PROMPT} {question}{AI_PROMPT}",
32 model="claude-sonnet-5",
33 stream=True,
34 max_tokens_to_sample=300,
35 )
36
37 async for completion in stream:
38 print(completion.completion, end="", flush=True)
39
40 print()
41
42
43def stream_error() -> None:

Callers 1

Calls 1

createMethod · 0.45

Tested by

no test coverage detected