API endpoint for token usage

Hi, wondering if there is an api call that I can use to get the following:



You can find the list of available endpoints in the API reference. There’s no endpoint for token usage.

Depending on why you would want it, there are plenty of alternatives I could think of. For example, you can use a tokenizer to count the number of tokens you’re processing, and multiply that by the relevant pricing - no need for a special API. The tokenizer page I linked to also links to repos with code to use programatically.

I am already using tiktoken to count tokens before processing and using the token counts in the response while processing. No issue with that. But this has to be tracked while processing.

What I wanted was to be able to have an api endpoint to check usage after the fact. Just as the screenshot of the page I posted shows details after the fact.