Skip to content

Instantly share code, notes, and snippets.

@jimmyliao
Last active November 7, 2023 03:00
Show Gist options
  • Save jimmyliao/af6fe01717531642984fc57e14c0b57b to your computer and use it in GitHub Desktop.
Save jimmyliao/af6fe01717531642984fc57e14c0b57b to your computer and use it in GitHub Desktop.
import openai
import os
import requests
from openai import OpenAI
client = OpenAI(
api_key=os.environ["OPENAI_API_KEY"],
)
response = client.chat.completions.create(
model="gpt-4-vision-preview",
messages=[
{
"role": "user",
"content": [
{"type": "text", "text": "What’s in this image?"},
{
"type": "image_url",
"image_url": "<YOUR_IMAGE_URL>",
},
],
}
],
max_tokens=300,
)
print(response.choices[0].message.content)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment