Image Inputs
Send an image as an image_url part in a chat message. The url can be a link to a public image or a base64 data URL. Use it to describe photos, read text (OCR), pull data from charts and screenshots, or compare images.
The samples use the OpenAI SDK set up as in the Quickstart.
From a URL
From a local file
Encode the file as base64 and send it as a data URL with the image’s MIME type.
Several images
Add one image_url part per image, in the same content list. How many images one request can carry depends on the model.
Formats
image/pngimage/jpegimage/webpimage/gif(on most models; animated GIFs are usually read as their first frame)
Tips
- Put the text first, then the images. If an image has to come first, put it in the system message.
- Size matters. Very large images are scaled down by the model and cost more tokens; send the resolution you need.
- Ask a specific question. “Read the total on this receipt” works better than “What is this?”.
Billing
Each image becomes input tokens at the model’s input price; how many depends on the model and the image’s size. Check usage.prompt_tokens on a first request. A model that doesn’t take images refuses the request with a 400 before anything is held.