I need my program to take a screenshot of the screen and then upload that into gpt4(I would like to use gpt4o if possible) , search the internet and then give me a response based off what its sees. But I cant seem to figure out the input for vision. Below is my code and the error that appears . Help would be appreciated
import keyboard
import pyautogui
import requests
import pyperclip
import io
import base64
def take_screenshot_and_process():
# Take a screenshot
screenshot = pyautogui.screenshot()
buffer = io.BytesIO()
screenshot.save(buffer, format='PNG')
image_base64 = base64.b64encode(buffer.getvalue()).decode('utf-8')
# Prepare the API request
headers = {
'Authorization': 'Bearer key'
'Content-Type': 'application/json',
}
data = {
"prompt": "Describe this image",
"model": "gpt-4",
"n": 1,
"size": "1920x1080",
"image": image_base64
}
# Send the request
response = requests.post('https://api.openai.com/v1/images/generations', json=data, headers=headers)
response_data = response.json()