diff --git a/src/openai/_streaming.py b/src/openai/_streaming.py index 45c13cc11d..684e0dd505 100644 --- a/src/openai/_streaming.py +++ b/src/openai/_streaming.py @@ -238,6 +238,15 @@ async def close(self) -> None: """ await self.response.aclose() + async def aclose(self) -> None: + """ + Alias for close() to support the standard Python async cleanup protocol. + + This allows AsyncStream to be used with asyncio utilities and libraries + that expect an aclose() method (e.g. contextlib.aclosing, httpx, anyio). + """ + await self.close() + class ServerSentEvent: def __init__(