The API doesn't even follow the format that OpenAI's chat endpoints take. You don't pass a single string to them. You pass an array of system/user/assistant messages. So this pricing won't be accurate<p>Not to mention this would be better replaced with a tokenizer lib and a multiplication operation
> The calculating method is based on the latest available pricing data released by OpenAI at <a href="https://openai.com/pricing" rel="nofollow noreferrer">https://openai.com/pricing</a>. However, please note that actual costs may vary and we cannot guarantee the price.<p>I guess in that case we can just use this as reference and calculate it by yourself<p>From <a href="https://help.openai.com/en/articles/4936856-what-are-tokens-and-how-to-count-them" rel="nofollow noreferrer">https://help.openai.com/en/articles/4936856-what-are-tokens-...</a><p>1 token ~= 4 chars in English<p>1 token ~= ¾ words<p>100 tokens ~= 75 words<p>Or<p>1-2 sentence ~= 30 tokens<p>1 paragraph ~= 100 tokens<p>1,500 words ~= 2048 tokens