fix(examples): refresh chat streaming examples (#2974)
## Summary Several example scripts still reference `poetry` in their shebangs and use the legacy Completions API, which is no longer documented in the README. This PR brings them up to date: - **Shebangs**: `demo.py`, `async_demo.py`, `streaming.py`, and `video.py` all used `#!/usr/bin/env -S poetry run python`. The project migrated to [Rye](https://rye.astral.sh/) and other examples (e.g. `audio.py`, `speech_to_text.py`) already use `rye run python`. Updated the four remaining files for consistency. - **Deprecated API**: `async_demo.py` and `streaming.py` used the legacy Completions endpoint (`client.completions.create` with `gpt-3.5-turbo-instruct`). This endpoint isn't referenced in the README and `gpt-3.5-turbo-instruct` is one of the last models supporting it. Migrated both to the Chat Completions API (`client.chat.completions.create`). - **Model name**: `demo.py` referenced `gpt-4`. Updated to `gpt-4o` to reflect current recommended usage. ## Changes | File | Change | |------|--------| | `examples/demo.py` | shebang `poetry` → `rye`, model `gpt-4` → `gpt-4o` | | `examples/async_demo.py` | shebang `poetry` → `rye`, `completions.create` → `chat.completions.create` | | `examples/streaming.py` | shebang `poetry` → `rye`, `completions.create` → `chat.completions.create` | | `examples/video.py` | shebang `poetry` → `rye` | ## Test plan - [x] `ruff check` passes on all modified files - [x] `ruff format --check` passes on all modified files - [x] Existing streaming tests (`tests/test_streaming.py`) pass - [x] `import openai` works correctly Co-authored-by: Marcus Wood <marcuswood@openai.com>
E
Eden committed
54f460ef8c212a7849d10cef69853dffb48c4491
Parent: d241ed6
Committed by GitHub <noreply@github.com>
on 9/15/2026, 6:10:01 PM