/openai_vision_example.py Secret
Created
February 27, 2025 14:18
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from openai import OpenAI | |
client = OpenAI() | |
response = client.chat.completions.create( | |
model="gpt-4o-mini", | |
messages=[ | |
{ | |
"role": "user", | |
"content": [ | |
{"type": "text", "text": "What's in this image?"}, | |
{ | |
"type": "image_url", | |
"image_url": { | |
"url": "https://cdn2.thecatapi.com/images/i5.jpg", | |
}, | |
}, | |
], | |
} | |
], | |
) | |
print(response.choices[0]) | |
# The image shows two cats snuggled together inside a cardboard box. | |
# One cat is orange and white, while the other is gray and white. | |
# They appear to be hugging each other, creating a very cozy and affectionate scene. | |
# The box has some writing on it, including the words "Bill Bills" on the side. | |
# The setting looks like a soft couch or similar furniture in the background. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment