How to view billing via API

Hi OpenAI Community,

We are developing scripts in Python/PowerShell to track our organization’s OpenAI spending. We previously tried:

  • GET /v1/dashboard/billing/subscription
  • GET /v1/usage?start_date=…&end_date=…

However, these methods no longer work with a standard API key (sk-key); they either require a browser session key or return empty arrays.

Question: Is there a way to retrieve the organization’s balance and current usage via API without using browser session keys?

If anyone has experience with this or knows any workaround, we would greatly appreciate your advice.
Alternatively, does OpenAI plan to add this functionality to the API?

Thank you in advance!

1 Like

Welcome to the community, @Igor_Kuznetsov .

Have you checked out the Usage API?

1 Like

Hi.
Yes, I’ve carefully studied “Today we’re launching a new API that lets you get granular API usage data, and a Costs endpoint that provides you with a breakdown of your daily spend. You can monitor token use by minute/hour/day, filter usage by API key, project ID, user ID, and model. https://platform.openai.com/docs/api-reference/usage” and can get my expenses for a period. Unfortunately, the task is to get the balance in my account. How can I find the amount at the beginning of the expense period, as well as the receipts during the expense period? Without this, I won’t be able to get the final balance using expenses. Please advise if there are other ways to get the final balance at the current moment.