Skip to content

Fix vision example to use Chat Completions API#2904

Open
tysoncung wants to merge 1 commit intoopenai:mainfrom
tysoncung:fix-vision-example-api-format
Open

Fix vision example to use Chat Completions API#2904
tysoncung wants to merge 1 commit intoopenai:mainfrom
tysoncung:fix-vision-example-api-format

Conversation

@tysoncung
Copy link

This PR fixes the vision examples in the README that were causing 400 errors when users tried to run them.

Problem: The vision examples were using the Responses API format which was causing 400 errors.

Solution: Updated to use the standard Chat Completions API which properly supports vision.

Changes:

  • Updated examples to use client.chat.completions.create()
  • Changed content types from input_text/input_image to text/image_url
  • Updated model from gpt-5.2 to gpt-4o (vision-capable model)
  • Changed image URL to a working example
  • Added print statements to show output

Fixes #2776

The vision examples were using the Responses API format which was
causing 400 errors when users tried to run the code. Updated to use
the standard Chat Completions API which supports vision through the
image_url content type.

Changes:
- Updated examples to use client.chat.completions.create()
- Changed content types from input_text/input_image to text/image_url
- Updated model from gpt-5.2 to gpt-4o (vision-capable model)
- Changed image URL to a working example
- Added print statements to show output

Fixes openai#2776
@tysoncung tysoncung requested a review from a team as a code owner February 28, 2026 00:14
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.

Vision example throws an error

1 participant