I've got a question about token usage. My latest request used this many tokens 645 prompt + 242 completion = 887 tokens When I count the characters in my promt myself, I get more characters than it calculated (1515). How does it calculate promt-characters? For example how does it handle empty spaces ect.?
additional question, when I set the max_tokens: does it include promt-tokens or is this only for comletion-tokens? I think it's for the whole request, promt+comnpletion, right?
#How to calculate tokens
3 messages · Page 1 of 1 (latest)
It's prompt + completion. You can find tokenizer here to mess around with https://platform.openai.com/tokenizer. They provide a js library at the bottom of the page and the python one is called tiktoken.
Very useful. "A helpful rule of thumb is that one token generally corresponds to ~4 characters ..." This explains it. Thanks