Open
Description
Confirm this is an issue with the Python library and not an underlying OpenAI API
- This is an issue with the Python library
Describe the bug
Hi,
I noticed a small but important issue in the streaming responses documentation, specifically in the async example.
In the async version of the streaming code, the following two issues appear:
- The call to client.responses.create(...) is missing an await.
- The loop over the stream uses for instead of async for.
Current code:
async def main(): stream = client.responses.create(...) # Missing 'await' for event in stream: # Should be 'async for' print(event)
Suggested fix:
async def main():
stream = await client.responses.create(...)
async for event in stream:
print(event)
To Reproduce
- Copy the async streaming example from the documentation: streaming responses documentation
- Run the script using Python 3.8+ with the latest openai package installed.
Code snippets
OS
any
Python version
Python 3.8+
Library version
v1.72.0