Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

ELI5 What is a token?

Is it a word, question, letter, what? If I ask a question like... What is the capital of Canada? And it responds with 'Ottawa', how many tokens have I used there and how are they calculated?



Roughly speaking, words or word parts. Open AI has an explainer:

https://help.openai.com/en/articles/4936856-what-are-tokens-...

You can also check your input using their tokenizer: https://platform.openai.com/tokenizer

So, your example is ~9 tokens


So does the response count towards the token count?


It does, yeah. It's tokens "processed", meaning request & response. The API response will give you a total token count so you can keep track


Token cost is prompt + response. In the case of ChatGPT you don't know the full prompt, but they don't charge by tokens for that app.

In the API you need to tokenize your input and tokenize the output then add the counts together.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: