Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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

Open
lucasalencarxisto-stack wants to merge 4 commits into openai:main
base: main
Choose a base branch
Loading
from lucasalencarxisto-stack:docs/examples-async-responses-stream

Conversation

Copy link

@lucasalencarxisto-stack lucasalencarxisto-stack commented Sep 19, 2025

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.

Copy link
Author

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!

Copy link
Author

@lucasalencarxisto-stack lucasalencarxisto-stack left a 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! 🙌

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers
No reviews
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /