-
Notifications
You must be signed in to change notification settings - Fork 4.3k
docs(examples): add async streaming examples for Responses and Chat #2645
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
docs(examples): add async streaming examples for Responses and Chat #2645
Conversation
Hi team, thanks for maintaining this project! 🙌
I noticed there wasn’t an async streaming example for the new Responses API, so I added one, along with a matching Chat Completions async streaming example for users still on that API. Hopefully this makes it easier for newcomers to try async/streaming right away. Feedback is very welcome!
30bae1d
to
c7c2686
Compare
c7c2686
to
57e5a0e
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just updated the PR to include the actual file contents (previously empty by mistake). The examples are now complete and ready for review. Thanks for your time! 🙌
This PR adds two new async streaming examples under examples/:
async_responses_stream.py – Demonstrates async streaming with the Responses API, which is now the recommended primary API.
async_chat_stream.py – Shows async streaming with Chat Completions, still supported indefinitely for users migrating gradually.
Both scripts:
Use AsyncOpenAI and asyncio.run(...).
Include a Rye shebang to follow the contributing guide.
Provide minimal, working async loops that print incremental events/chunks for demo purposes.
These additions improve developer experience by providing clear, runnable async/streaming examples for both the new and legacy APIs without modifying existing examples.