How can i check OpenAI usage with Python?

Hi, i want to check my usage with API in Python and i’ll publish on my website.

How can i do this?

Hi @Gelistirici,

you can use the API-response to figure out the amount of tokens used. You can use this data to figure out the total token usage and work with.

I’m not sure if this helps but there are no other ways mentioned from OpenAI’s end…

Source:

How do I check my token usage? | OpenAI Help Center

1 Like

To specify: Extract the token - usage from the JSON, convert to integer and then add this to a variable where you store your token usage.

1 Like