You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can define a callable using the logic below to display current API usage stats for the present day within the chat runtime.
importdatetimer=openai.api_requestor.APIRequestor()
resp=r.request("GET", f'/usage?date={datetime.datetime.now().strftime("%Y-%m-%d")}')
resp_object=resp[0]
resp_object.data# this object has all the inforequests_today=resp['data'][0]['n_requests'] # num requestsquery_tokens_today=resp['data'][0]['n_context_tokens_total'] # query tokensresponse_tokens_today=resp['data'][0]['n_generated_tokens_total'] # response tokens
Provide users with insights into their API usage, response patterns, and other metrics to help them optimize their interactions with ChatGPT.
The text was updated successfully, but these errors were encountered: