From 93ebb5747b309dce8d39b49aef7b3684a594960b Mon Sep 17 00:00:00 2001 From: nightcityblade Date: Sat, 21 Feb 2026 23:09:20 +0800 Subject: [PATCH] fix: add aclose() method to AsyncStream for PEP 525 compliance AsyncStream only exposed close() but not aclose(), causing AttributeError when callers use the standard Python async cleanup convention (e.g. instrumentation libraries calling response.aclose()). Fixes #2853 --- src/openai/_streaming.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/openai/_streaming.py b/src/openai/_streaming.py index 61a742668a..1ed89b9e18 100644 --- a/src/openai/_streaming.py +++ b/src/openai/_streaming.py @@ -223,6 +223,10 @@ async def close(self) -> None: """ await self.response.aclose() + async def aclose(self) -> None: + """Alias for :meth:`close` following the PEP 525 async cleanup convention.""" + await self.close() + class ServerSentEvent: def __init__(