I have been sending an image to gpt api with gpt-4o as model by enoding the image as base64.
Normally I calculate the cost for a single api call based on the input and output tokens in response[‘usage’].
What about in case of sending image as base64 encoding? will the above cost calculation method still the same or any changes that are need to be done.
path = f'imu/{ticker}'
base64_image = self.encode_image(f"{path}/page_{content_page}.jpg")
image_url = f"data:image/jpeg;base64,{base64_image}"
images_info = []
images_info.append(
{
"type": "text",
"text": "This is the image that should be taken as context to give the output",
}
)
image_dict = {
'type': "image_url",
"image_url": {
"url": image_url
},
}
images_info.append(image_dict)
messages.append(
{
"role": "user",
"content": images_info
}
)
prompt = ANNUAL_REPORT_SPLITTER_PROMPT3
data, messages = self.get_gpt_response(prompt, messages, model="gpt-4o")