fix: Fix SDK async streaming - use create(stream=True) instead of stream()
The Anthropic SDK's messages.stream() is a synchronous context manager,
not async. For async streaming, we need to use messages.create(..., stream=True)
which returns an async iterator of ServerSentEvent objects.
Changed from:
async with client.messages.stream(**request_kwargs) as stream:
To:
stream = await client.messages.create(**request_kwargs, stream=True)
async for event in stream:
Showing
This diff is collapsed.
Please
register
or
sign in
to comment