An error message of “TypeError: Object of type bytes is not JSON serializable” is received as trying to input an image as raw bytes.
with open('download.png', 'rb') as file:
raw_bytes = file.read()
content = ["Describe the image!"]
content.append({"image": raw_bytes})
response = openai.ChatCompletion.create(
model="gpt-4-0314",
messages=[
{"role": "system", "content": "You are a helpful assistant."},
{"role": "user", "content": content}
]
)