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

Function sync_stream

examples/text_completions_streaming.py:15–26  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

13
14
15def sync_stream() -> None:
16 stream = client.completions.create(
17 prompt=f"{HUMAN_PROMPT} {question}{AI_PROMPT}",
18 model="claude-sonnet-5",
19 stream=True,
20 max_tokens_to_sample=300,
21 )
22
23 for completion in stream:
24 print(completion.completion, end="", flush=True)
25
26 print()
27
28
29async def async_stream() -> None:

Callers 1

Calls 1

createMethod · 0.45

Tested by

no test coverage detected