Returning Token consumption costs of models with API

We list the models in openai.models.list() . Using a similar method, for example, by calling a function like openai.models.getTokenBilling() , we get the information on the “https://openai.com/api/pricing/” page of the models.

The purpose of this is to automate our billing update processes by sending hourly, daily, and weekly requests for this data that we keep locally as a result of the request.

1 Like