Hello,
I’m using the completion API for a personal project, and I’d really like to know what are the remaining (free) credits on my account ?
Is such endpoint exists ?
Thanks in advance
Hello,
I’m using the completion API for a personal project, and I’d really like to know what are the remaining (free) credits on my account ?
Is such endpoint exists ?
Thanks in advance
To be clear, you’re looking to be able to check your account usage stats via an api call instead of manually checking through the “Manage Account > Usage” page, correct?
Yeah I think that’s what he meant, I would also like to know the answer to this question.
There is current no documented OpenAI API endpoint to access account information.
Would be great if there was
There are a couple of API endpoints which expose your usage & credits
https://api.openai.com/v1/usage
https://api.openai.com/dashboard/billing/credit_grants
I have been working on an #unofficial PowerShell Module to expose them. https://www.powershellgallery.com/packages/PS-OpenAI/
It’s basic, but it shows the endpoints I have found and what’s required to get a valid API response.
This is the output for my credit_grants
. (I have redacted my id
to publish here)
{
"object": "credit_summary",
"total_granted": 18.0,
"total_used": 0.6284545,
"total_available": 17.3715455,
"grants": {
"object": "list",
"data": [
{
"object": "credit_grant",
"id": "bdb804***********************ff0132",
"grant_amount": 18.0,
"used_amount": 0.6284545,
"effective_at": 1673740800.0,
"expires_at": 1682899200.0
}
]
}
}
Hope this helps.
Enjoy.
M
Hi @mc1903
Thank you very much for those two undocumented API endpoints! I heard rumors someone had reversed engineered these.
Do you have other undocumented API endpoints, or are those the only two?
Thanks!
Take a look through the GitHub repo https://github.com/mc1903/PS-OpenAI and you will find the url in each of the functions under /Src/Public/
They use the [uri]$url = "https://api.openai.com/*"
variable.
Just be aware that some of the totals return a value 100x the actual usage.
For instance my billing for yesterday was 0.05 (5 cents), but the https://api.openai.com/dashboard/billing/usage
endpoint returns my total_usage as 4.562
{
"object": "list",
"daily_costs": [{
"timestamp": 1674691200.0,
"line_items": [{
"name": "Base",
"cost": 4.562
},
{
"name": "FT Training",
"cost": 0.0
},
{
"name": "FT Inference",
"cost": 0.0
},
{
"name": "Embeddings",
"cost": 0.0
},
{
"name": "DALL-E API",
"cost": 0.0
}
]
}],
"total_usage": 4.562
}
Where as the webpage shows it as:
Enjoy.
M