From 26eb97b4c92c0d96a72dddbb8ba526ccbd6fdfff Mon Sep 17 00:00:00 2001 From: Matt Van Horn Date: Tue, 10 Mar 2026 01:02:32 -0700 Subject: [PATCH] fix(streaming): add aclose() alias to AsyncStream AsyncStream exposes close() but not aclose(), causing AttributeError when callers use the standard Python async cleanup convention. This surfaces with instrumentation libraries (e.g. Langfuse) that wrap the raw stream and call aclose(). Fixes #2853 Co-Authored-By: Claude Opus 4.6 --- src/openai/_streaming.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/openai/_streaming.py b/src/openai/_streaming.py index 45c13cc11d..a15aa9f7de 100644 --- a/src/openai/_streaming.py +++ b/src/openai/_streaming.py @@ -238,6 +238,10 @@ async def close(self) -> None: """ await self.response.aclose() + async def aclose(self) -> None: + """Alias for :meth:`close`, following the standard Python async convention.""" + await self.close() + class ServerSentEvent: def __init__(