OpenAi API - get usage tokens in response when set stream=True

However, after extensive testing, I found that the token value calculated by the calculator for offline token calculation is far from the actual value used. So Python’s tiktoken is not reliable.
However, please find attached the method I am currently using to calculate tokens:

  1. Each stream containing an answer is treated as a token, and when all these streams are added up, they are equal to all the tokens in this question. This is the method for calculating the response token.
  2. The token method used for questioning can be implemented using tiktoken (which is really impossible). Ha ha ha
1 Like