sps
11
Yes @DutytoDevelop, you should definitely write on it. I can’t wait to read your post.
1 Like
If I understand @dhruvbhardwaj3012’s question correctly, they want to track usage for the end users of their product, whereas the solution posted above pulls usage for OpenAI users who are members of your organization.
While we do allow you to pass a end user ID along with your requests, we do not currently support querying usage by these end user identifiers. For now you would have to build a custom system that tracks in your own database how many requests / tokens each of your customers is using.
6 Likes
Ah, thanks for the clarification! I was under the impression that end users that signed up for a service that uses GPT-3 would be added into the service owner’s OpenAI organization.
Thanks @dschnurr!
1 Like
Ooh, yeah. Something like this would be cool if it pulled from the USERID you can now send to the API?
2 Likes
Exactly David! We understood it as well. Also, cant thank @DutytoDevelop for his help. Thank you for the detailed answer. Glad to learn from you
1 Like
benb
17
Is support for this on the roadmap?
Hi Nicholas @DutytoDevelop thanks for the code!
I just tried to run it and there was this error message:
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest)
[Invoke-WebRequest], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.I
nvokeWebRequestCommand
Invoke-WebRequest : {
“error”: {
“message”: “Missing query parameter ‘date’”,
“type”: “invalid_request_error”,
“param”: null,
“code”: null
}
}
Is this because the API of OpenAI has been updated since then? Could you please tell me how to fix this? Thanks!
I am also interested in a similar feature for tracking user token utilization, in a way that user’s pay for their own tokens directly, without having to create an OpenAI account. For example, child elements with their own secret key, tracking their own usage, and each one can have their own payment method tied directly to their key. However, rather than having a “reader” access, I wouldn’t want them to be able to see organizational data such as who the other customer’s are. Some sort of bridge between the customer model and the organizational model. Having a more simple route of abstraction would do wonders.
This is amazing, thanks for sharing this. Would you be willing to share a python version of this code?
Well, you will need to create these users in your DB, right? So why not add token usage to your DB as well - you will know who is using OpenAI and with response you will receive number of tokens, which you will save into your DB and connect with the user that used it. That way, you could show them exactly what they are paying for.
I have the token usage tied to the user in the DB. I’m talking about a bridge that removes me as the middleman. Because Stripe charges about 3%, so I would have to charge a minimum of 3% of total token usage of the user just to break even. I’d rather only have to charge like a monthly subscription fee to use my product.
1 Like
Is there a way to track the usage of each API key generated?
I need to keep track of usage by API key used by different projects.
4 Likes
I wrote a command line tool using nodejs, ref: https://community.openai.com/t/use-cli-to-batch-download-the-usage-data-of-openai-api/127734
Note that the usage data given by openai may exceed expectations. For example, I saw a message about using 152k tokens last month. Someone explained it here, but it is still very strange. ref: https://community.openai.com/t/what-is-n-context-tokens-total-why-is-it-so-large/127420
1 Like
I also need something like this. Tracking usage with each key would be very helpful.
2 Likes
Is there any progress on python scripts? Why OpenAI couldn’t simply present a user chart for organization owner in the website to track per user usage?
3 Likes
Been tracking this conversation because I’m having the same problem. Made a quick tool I call: Token Chihuahua 
The loyal watchdog your team needs to track API costs.
A simple Usage tool with per account filters. Try it out. Let me know what you need to make life easier.
Hello @boyu.niu and everyone else!
Apologies with the late reply. I will take a look either tonight or tomorrow night to see how to make the script work again, as well as write it so it works in Python, Bash, and PowerShell.
Regarding the Python script version, I could also quickly make out a GUI to allow for broader accessibility to tracking individual usage with the script.
2 Likes
I wish I can give you 1000 stars if you open-source them
Hello
Do you have the latest script that can check user usage?
I used the above script and he reported an error. Has the OpenAI backend been unable to view the usage of each user recently
Hello
Do you have the latest script that can check user usage?
I used the above script and he reported an error. Has the OpenAI backend been unable to view the usage of each user recently