OpenAI API prices vs tokens when upload files

If I order a GPT-4 API Model and I want to use that to upload Files because I want to work with this. How many tokens are a File or what other things do I have to consider and how would they be priced?

Hi mate, !

you can use the NLTK python library to count tokens.

import nltk
en = "hi! how are you? "

We also have this library GitHub - openai/tiktoken: tiktoken is a fast BPE tokeniser for use with OpenAI's models. which help us to count and vectorize words/tokens.

to get final price, you can calculate with the pricing table:

Those screenshots could give one idea :v:

Screenshot 2024-01-16 at 1.38.25 AM

1 Like

Hi Mike,

Thank you for your answer but that don’t resolve my doubt.

How the API counts a file upload? 1 token is 1 File? or it’s depends on number of pages.

File retrieval is model independent I believe.

You don’t upload a file to a model, you upload it for use in the Assistant API:


“Retrieval is priced at $0.20/GB per assistant per day. Attaching a single file ID to multiple assistants will incur the per assistant per day charge when the retrieval tool is enabled. For example, if you attach the same 1 GB file to two different Assistants with the retrieval tool enabled (e.g., customer-facing Assistant #1 and internal employee Assistant #2), you’ll be charged twice for this storage fee (2 * $0.20 per day). This fee does not vary with the number of end users and threads retrieving knowledge from a given assistant.”


1 Like

so if i upload one, and don’t attach it to any assistants, im charged nothing? it can live there for free forever?

1 Like

My understanding aligns with yours, and I hope someone can confirm whether it’s indeed the case.

1 Like

When uploading a file you have to pay for the storage and the ability to attach it to a assistant.

It’s a possibility to not add a file to an assistant but you will still have to pay.
That’s the baseline.

Also, don’t forget to check if there are any pricing updates. Sometimes new features are free for a limited period of time.