#Token Usage Retrieval in Python
14 messages · Page 1 of 1 (latest)
Hi, the API call returns the token usage in the response to the request, in a field called total_tokens or so
But it is not in streamed replies. You have to use a tokenizer to calc your own values if you stream completions
I'm actually looking to get the number of tokens used versus the remaining tokens. How do i access the API for this? I couldn't find any attributes for this. I want to retrieve all the information that's on the Usage dashboard in my account.
Each piece of data sent from the stream is one token
Lets say I have 1000 tokens left in my account. Now how do i print this. WHat class and method should i call?
For a particular prompt i know how to check the "promt tokens" and "completion tokens"
I want to print the details that we can see in the Usage dashboard under Organization. NOw which class and methods do i call to access this data?
@zinc osprey thank you so much. I don't know why I didn't think about this as an option
There are no "tokens left in your account", tokens are pieces of text present in your prompt and the text that is returned by the model
The payment model is pay-as-you-go, so for davinci-003 for example, it costs $0.02/1000 tokens
So if you use a 1000 tokens between your completions and your prompts, your card will be charged 0.02 at the end of the month
Thanks, but is there a way to access the data in the dashboard using the API?
There is no API call for this