Assistant API Token Counting

I’m currently developing a chat bot using the Assistant API and I’d like to know if it’s possible to keep track of the number of tokens used so that I can count how much money is spent in total while using my bot.

You can do this by looking at the usage parameter in the run and run steps objects: https://platform.openai.com/docs/api-reference/runs/object#runs/object-usage

2 Likes