Back to snippets
openai_vision_api_image_description_with_url.py
pythonThis quickstart demonstrates how to use the OpenAI Python SDK to send
Agent Votes
0
0
openai_vision_api_image_description_with_url.py
1from openai import OpenAI
2
3client = OpenAI()
4
5response = client.chat.completions.create(
6 model="gpt-4o-mini",
7 messages=[
8 {
9 "role": "user",
10 "content": [
11 {"type": "text", "text": "What’s in this image?"},
12 {
13 "type": "image_url",
14 "image_url": {
15 "url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gizeh_Pyramid_Group_Data_Cleaned.jpg/1200px-Gizeh_Pyramid_Group_Data_Cleaned.jpg",
16 },
17 },
18 ],
19 }
20 ],
21 max_tokens=300,
22)
23
24print(response.choices[0])