# Pricing, Billing and Tokens? Math is not adding up

**URL:** <https://community.openai.com/t/pricing-billing-and-tokens-math-is-not-adding-up/254074>\
**Category:** API\
**Tags:** api\
**Created:** [June 7, 2023, 3:56am UTC](https://community.openai.com/t/pricing-billing-and-tokens-math-is-not-adding-up/254074 "2023-06-07T03:56:27Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![Somf](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@Somf](https://community.openai.com/u/Somf)\
**Post date:** [June 7, 2023, 3:56am UTC](https://community.openai.com/t/pricing-billing-and-tokens-math-is-not-adding-up/254074/1 "2023-06-07T03:56:27Z")

</div>

Hi all.

I decided to give the API a shot after being blown away at the chatGPT web app. I created a basic chatGPT clone to see if it was possible to replicate.

Currently the issue I am concerned with is the billing/charging of requests since the impression I got on the pricing page is far different than what I am experiencing in reality.

I based my calculations on the token system. 1 token = 4characters. I am currently using gpt-3.5-turbo and implemeting it through PHP Curl.

Endpoint:  
[https://api.openai.com/v1/engines/davinci/completions](https://api.openai.com/v1/engines/davinci/completions)

## Options: max\_tokens = 1000, temperature = 0.2, n = 1, logprobs = 0, stop = \nAssistant:

Pricing: [https://openai.com/pricing](https://openai.com/pricing)  
gpt-3.5-turbo $0.002 / 1K tokens

Based on that pricing it was my assumption based off 1 token = 4 chars. That would be 4000 chars of requests/responses at a cost of $0.002 but that is not what I am seeing in reality.

Below is an example of requests and responses I just did to test.

* * *

## ME: who is the president of the US? AI: Joe Biden. ME: can you write me a poem about flowers? AI: I’m sorry, I don’t understand. ME: how do say hello in french? AI: Merci. ME: what is the largest continent on earth? AI: Paris

Total cost for this exchange in my Usage section under my account is **$0.08**. In a production environment at these rates it would get very expensive very quickly.

Am I just doing something obviously wrong here or is this something other people are experiencing?

Any suggestions or replies would be helpful so that I can get to the bottom of this. I am excited to start using this tech.

All the best!

---

<div class="post-metadata">

**Author:** ![novaphil](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/novaphil/32/130934_2.png) [@novaphil](https://community.openai.com/u/novaphil)\
**Post date:** [June 7, 2023, 4:14am UTC](https://community.openai.com/t/pricing-billing-and-tokens-math-is-not-adding-up/254074/2 "2023-06-07T04:14:58Z")

</div>

> [@Somf](#):
>
> Endpoint:  
> [https://api.openai.com/v1/engines/davinci/completions](https://api.openai.com/v1/engines/davinci/completions)

Thats Davinci, not GPT3.5. Different pricing

---

<div class="post-metadata">

**Author:** ![Somf](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@Somf](https://community.openai.com/u/Somf)\
**Post date:** [June 7, 2023, 4:33am UTC](https://community.openai.com/t/pricing-billing-and-tokens-math-is-not-adding-up/254074/3 "2023-06-07T04:33:23Z")

</div>

Thanks for the response.

I am getting mixed messages on that from the webApp AI.

[https://api.openai.com/v1/chat/completions](https://api.openai.com/v1/chat/completions)  
Said that was an old chat, gave me this one for turbo:  
[https://api.openai.com/v1/engines/davinci/completions](https://api.openai.com/v1/engines/davinci/completions)

Today I asked a similar question and it gave me this endpoint.  
[https://api.openai.com/v1/engines/davinci-codex/completions](https://api.openai.com/v1/engines/davinci-codex/completions)

in any case, even if you factor in the different pricing. the math still does not add up for me.

Cheers!

---

<div class="post-metadata">

**Author:** ![novaphil](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/novaphil/32/130934_2.png) [@novaphil](https://community.openai.com/u/novaphil)\
**Post date:** [June 7, 2023, 4:57am UTC](https://community.openai.com/t/pricing-billing-and-tokens-math-is-not-adding-up/254074/4 "2023-06-07T04:57:40Z")

</div>

Don’t trust GPT, it wasn’t trained on the docs. Look at the docs, they’re pretty decent.

- [GPT Guide](https://platform.openai.com/docs/guides/gpt)
- [GPT API Reference](https://platform.openai.com/docs/api-reference/chat)

Were you including chat history in each request? You’ve used the API Key only for those messages you shared?

You can look at [Usage page](https://platform.openai.com/account/usage) and select the day under Daily usage to see number of requests and tokens it counted. Also token counts are returned in API response, since it’s not as simple as 4 characters = 1 token

---

<div class="post-metadata">

**Author:** ![Somf](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@Somf](https://community.openai.com/u/Somf)\
**Post date:** [June 7, 2023, 5:27am UTC](https://community.openai.com/t/pricing-billing-and-tokens-math-is-not-adding-up/254074/5 "2023-06-07T05:27:10Z")

</div>

Thanks for the response. the webApp api is a bit all over the place.

I reverted back to the [https://api.openai.com/v1/chat/completions](https://api.openai.com/v1/chat/completions) endpoint and my chat responses to questions are orders of magnitude better quality. not sure what is going on with the AI in those examples i posted with that other endpoint.

Brilliant! I’ve been looking for the token request stats since i opened the account but couldn’t find it.

## Here is the results: 03:00 Local time: 7 Jun 2023, 13:00 davinci, 1 request 13 prompt + 1,000 completion = 1,013 tokens 03:05 Local time: 7 Jun 2023, 13:05 davinci, 1 request 14 prompt + 1,000 completion = 1,014 tokens 03:10 Local time: 7 Jun 2023, 13:10 davinci, 1 request 12 prompt + 1,000 completion = 1,012 tokens 03:15 Local time: 7 Jun 2023, 13:15 davinci, 1 request 13 prompt + 1,000 completion = 1,013 tokens

Here is the result after I switched back to the /v1/chat/completions endpoint

## 04:55 Local time: 7 Jun 2023, 14:55 gpt-3.5-turbo-0301, 2 requests 45 prompt + 106 completion = 151 tokens

The second Turbo example is much closer to my calculations although the 1Token=4Character thing doesn’t seem to be correct. Removing whitespace my prompt was 50 Chars and Response was 1128 Chars.

The Divinci model is extremely confusing especially considering the poor quality of the answers from my original post.

Thanks for all the help!

---

<div class="post-metadata">

**Author:** ![novaphil](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/novaphil/32/130934_2.png) [@novaphil](https://community.openai.com/u/novaphil)\
**Post date:** [June 7, 2023, 5:28am UTC](https://community.openai.com/t/pricing-billing-and-tokens-math-is-not-adding-up/254074/6 "2023-06-07T05:28:48Z")

</div>

Compare against the actual tokenizer logic using the [token calculator](https://platform.openai.com/tokenizer)

---

<div class="post-metadata">

**Author:** ![Somf](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@Somf](https://community.openai.com/u/Somf)\
**Post date:** [June 7, 2023, 5:30am UTC](https://community.openai.com/t/pricing-billing-and-tokens-math-is-not-adding-up/254074/7 "2023-06-07T05:30:34Z")

</div>

Excellent! Thanks for that.

A quick question on the “chat history”. is that included in the tokens usage?

Thanks again.

---

<div class="post-metadata">

**Author:** ![novaphil](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/novaphil/32/130934_2.png) [@novaphil](https://community.openai.com/u/novaphil)\
**Post date:** [June 7, 2023, 5:51am UTC](https://community.openai.com/t/pricing-billing-and-tokens-math-is-not-adding-up/254074/8 "2023-06-07T05:51:47Z")

</div>

API is stateless, so you need to send any chat history messages as additional prompts. You are responsible for pruning/summarizing the history to keep it under token limit. And you are charged for the full request, so all the past messages you send.

---

<div class="post-metadata">

**Author:** ![Somf](https://avatars.discourse-cdn.com/v4/letter/s/22d042/32.png) [@Somf](https://community.openai.com/u/Somf)\
**Post date:** [June 7, 2023, 5:56am UTC](https://community.openai.com/t/pricing-billing-and-tokens-math-is-not-adding-up/254074/9 "2023-06-07T05:56:26Z")

</div>

Ok cool. I will just store the history locally.

Thanks again for all your help!

---

<div class="post-metadata">

**Author:** ![curt.kennedy](https://sea2.discourse-cdn.com/openai1/user_avatar/community.openai.com/curt.kennedy/32/709249_2.png) [@curt.kennedy](https://community.openai.com/u/curt.kennedy)\
**Post date:** [February 16, 2024, 1:38am UTC](https://community.openai.com/t/pricing-billing-and-tokens-math-is-not-adding-up/254074/10 "2024-02-16T01:38:09Z")

</div>


