#Token Usage Retrieval in Python

14 messages · Page 1 of 1 (latest)

tacit blaze
#

I'm trying to retrieve the token usage data in Python. I'm unable to access the correct classes and methods. I need help with where I can find the attributes that are required to write code so that I can retrieve the token/API usage details.

half patio
weak ocean
#

But it is not in streamed replies. You have to use a tokenizer to calc your own values if you stream completions

tacit blaze
#

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.

zinc osprey
tacit blaze
#

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?

weak ocean
#

@zinc osprey thank you so much. I don't know why I didn't think about this as an option

half patio
#

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

tacit blaze
#

Thanks, but is there a way to access the data in the dashboard using the API?

weak ocean
#

There is no API call for this