Skip to content

fix(examples): update outdated shebangs and deprecated API usage#2974

Open
edenfunf wants to merge 1 commit intoopenai:mainfrom
edenfunf:fix/update-outdated-examples
Open

fix(examples): update outdated shebangs and deprecated API usage#2974
edenfunf wants to merge 1 commit intoopenai:mainfrom
edenfunf:fix/update-outdated-examples

Conversation

@edenfunf
Copy link

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 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 poetryrye, model gpt-4gpt-4o
examples/async_demo.py shebang poetryrye, completions.createchat.completions.create
examples/streaming.py shebang poetryrye, completions.createchat.completions.create
examples/video.py shebang poetryrye

Test plan

  • ruff check passes on all modified files
  • ruff format --check passes on all modified files
  • Existing streaming tests (tests/test_streaming.py) pass
  • import openai works correctly

- Replace `poetry run python` shebangs with `rye run python` to match
  the project's current tooling (demo.py, async_demo.py, streaming.py,
  video.py)
- Migrate async_demo.py and streaming.py from the legacy Completions API
  (`client.completions.create` with gpt-3.5-turbo-instruct) to the Chat
  Completions API (`client.chat.completions.create`)
- Update model references from gpt-4 to gpt-4o in demo.py
@edenfunf edenfunf requested a review from a team as a code owner March 14, 2026 06:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant