Confirmation of Request Source
Describe the feature you'd like
While working on pydantic/pydantic-ai#1524 I hit: Chat.stream() (in xai_sdk.aio.chat) only exposes the async generator, so cancelling it from another task while we're iterating raises RuntimeError: aclose(): asynchronous generator is already running.
A transport handle we could close/cancel directly — exposing the underlying UnaryStreamCall (or a wrapper with cancel() / close() on it), like the OpenAI (AsyncStream.close()) and
Anthropic (AsyncStream.close()) SDKs do. Would be nice to be able to do the same here.
Parallel issue on google-genai: googleapis/python-genai#2425
Additional Context
No response
Confirmation of Request Source
Describe the feature you'd like
While working on pydantic/pydantic-ai#1524 I hit:
Chat.stream()(in xai_sdk.aio.chat) only exposes the async generator, so cancelling it from another task while we're iterating raisesRuntimeError: aclose(): asynchronous generator is already running.A transport handle we could close/cancel directly — exposing the underlying
UnaryStreamCall(or a wrapper with cancel() / close() on it), like the OpenAI (AsyncStream.close()) andAnthropic (AsyncStream.close()) SDKs do. Would be nice to be able to do the same here.
Parallel issue on google-genai: googleapis/python-genai#2425
Additional Context
No response