Evaluating image processing costs if sending images using Base64

Hello, I am currently having a dilemma on whether I should host my images that I send to the OpenAI API or just use base64 encoded strings as the urls.

Does the API tokenize these massive strings and add to costs, or do the costs not change regardless whether it’s a base64 encoded string or URL?

Welcome to the developer forum, @damjan.avramovski.

The images encoded as base64 data sent to the API in the image_url block are not tokenized as regular text strings.

The cost of processing images for vision depends on their resolution and the level of detail.

Here’s a guide on how the costs for vision are calculated: image costs are calculated for vision.

The pricing page also has image cost calculators for the models that support vision.

The decision to host your own images or send them as base64-encoded data depends on the nature of your usage.

If you’re sending a large number of images, you might find it faster and more reliable to send the images as URLs instead of base64 data.

1 Like

Urls are the prefered machanism as there are economies of scale with external providors for managing cashing and the like, but there are circumstances were the owners of the domain the URL points to either don’t want an OpenAI server accessing it or the reliability of the server/bandwidth is in question and so base64 is provided for for that purpose and to allow locally generated or modified images to be uplaoded without having to host them first.

1 Like