For a picture, I calculate the pixels to be 1900*1900 / / 223KB.
The cost of using URL to transfer is US$0.003825, by gpt price. But I have not successfully transferred to GPT. So there’s no way to know the actual cost at this time.
I have used base64 encoding for transmission and consumed more than 100,000 tokens.
Can someone tell me, does both transfer methods cost the same?
Sorry, I uploaded it a few days ago. Records in PYcharm are not retained. But I have a situation of API consumption. I spent nearly $5 that day. Since I’m a beginner, I had GPT return records that consumed a tonken of proficiency.
on 19 Jun, when I first upload the file, it prompts me for more than a single transfer token. So I divided the base64 encoding into about 30 parts for transmission. The base64 encoding of an image is divided into 30 parts.
That’s what I do.
I have never learned any programming , so I wrote the codes with GPT guidance. Although I made this mistake, I still want to say that GPT is a great project.
A bit late to answer, but in case someone comes across this post in the future:
In my tests, the cost of tokens when using base64 for input images was very different from the cost mentioned in the pricing calculator at https://openai.com/api/pricing/
After searching for a while, I found that in the documentation there is an example for input images, using the API itself to store an image and get its ID. So, in your query, just point to this ID instead of base64
I hope I helped someone
from openai import OpenAI
client = OpenAI()
# Function to create a file with the Files API
def create_file(file_path):
with open(file_path, "rb") as file_content:
result = client.files.create(
file=file_content,
purpose="vision",
)
return result.id
# Getting the file ID
file_id = create_file("path_to_your_image.jpg")
response = client.responses.create(
model="gpt-4.1-mini",
input=[{
"role": "user",
"content": [
{"type": "input_text", "text": "what's in this image?"},
{
"type": "input_image",
"file_id": file_id,
},
],
}],
)
print(response.output_text)