Gpt-4-turbo-2024-04-09 not accepting images?

Hi!
I have the same issue with gpt-4-turbo-2024-04-09

  • for an image as URL - error Expected a base64-encoded data URL with an image MIME type
  • for am image as base64 - error Invalid content type. image_url is only supported by certain models.
import base64
from openai import OpenAI

client = OpenAI(
    api_key=os.environ.get("OPENAI_API_KEY"),
)

image_file = "test_file.jpg"

with open(image_path, "rb") as image_file:
    image_url_base64 = base64.b64encode(image_file.read()).decode("utf-8")

image_url = f"data:image/jpeg;base64,{image_url_base64}"

chat_completion = client.chat.completions.create(
    messages=[
        {
            "role": "user",
            "content": [
                {"type": "text", "text": "describe a picture"},
                {"type": "image_url", "image_url": {"url": image_url, "detail": "high"}},
            ],
        },
    ],
    model="gpt-4-turbo-2024-04-09",
)

print(chat_completion)

And with gpt-4-vision-preview model both requests are ok.

UPD: Yeah, with gpt-4-turbo it’s ok

1 Like