400 Error when I include base64 image in a prompt

You don’t modify the contents of a base64 unless you want to corrupt it.

This is the format of message that must be sent to chat completions:

[
    {
        "role": "system",
        "content": [
            {"type": "text", "text": system_prompt}
        ]
    },
    {
        "role": "user",
        "content": [
            {"type": "text", "text": "Describe this art style."},
            {
                "type": "image_url",
                "image_url": {"url": f"data:image/jpeg;base64,{encoded_string}"}
            }
        ]
    }
]

Assistants does not accept base64 images.

2 Likes