Base64 represents binary data as a printable string using a 64-character alphabet. It groups three bytes (24 bits) into four characters (6 bits each). For images sent to GPT-4o, encode the binary image data with Base64, then decode the result as UTF-8 text for inclusion in a prompt. section 6.3.2
Encoding a local image
Read a picture in binary mode and encode its bytes with Python’s base64 library. In a people-tagging workflow, the encoded images are paired with instructions asking GPT-4o whether two pictures show the same person. section 6.3.2 section 6.3.4
with open(image_path, 'rb') as image_file:
encoded = base64.b64encode(image_file.read())
This Python snippet reads an image file as bytes and Base64-encodes it. section 6.3.2
The same conversion applies to video frames: encode a frame as a JPEG image, Base64-encode its binary buffer, and decode the result as UTF-8 before adding it to a prompt. section 6.4.2






