Whenever you send a prompt in to an LLM, of course it's going to cost you tokens. But how many tokens? Well, you can easily see your token usage with the usage property on the result from the generateText function. I've already run this 7-usage script, and here is the output.
We get an object with quite some detail about the tokens that were used. We have input tokens, of course broken up and displayed separately from output tokens. So input tokens are all of those that make up the prompt that we send in. Back inside of our terminal, we can also see the output tokens.
Now the details for these output tokens are broken down into two different properties. The text tokens, that is the token count for the actual textual response that we get back, as well as reasoning tokens. Some models these days are quote unquote thinking models. And these reasoning tokens account for the tokens that are returned for that thinking process.
So the total output tokens is a combination of the text tokens and reasoning tokens taken to complete the output. And of course the total tokens is how many tokens were used for both input and output. You might be wondering what these input token details are all about. They all mention the word cache.
Well, we'll talk about that in the next lesson.