How is GPT-4 API pricing calculated?

I’ve been using the GPT-4 model by integrating the OpenAI API into VS Code through a continue extension. After making 10 requests to modify my code, my usage shows around 33k tokens consumed with a cost of approximately $1.13. Could someone clarify how this amount is calculated? Is the pricing based solely on the number of tokens, on the number of API requests, or on a combination of both?

1 Like

“GPT-4” by name is “gpt-4-0613” as in 2023-06-13. It is a full-scale expensive model.

You are billed by the input that you send, and even more by the output it produces, in terms of tokens, an encoder that is a sort of data compression.

https://openai.com/api/pricing/

The only per-use fees are internal tools on the Responses endpoint, where each of file_search, web_search, and code_interpreter have additional invocation fees.

If you want good cheap coding, you’ll probably want o4-mini.

1 Like