Billing Usage API requires session key,backend requests failing

I’m building an internal usage dashboard and tried calling:

GET /v1/dashboard/billing/usage

from my backend using a normal server-side API key. The request fails. I have the correct API key, org ID, and project ID, and billing is active, but the endpoint still rejects server-side keys.

Question:
Is this endpoint restricted to dashboard session keys only?
If yes, what is the correct way for backend servers to fetch usage/cost data programmatically?
Is that even possible to fetch usage etc from OPEN AI to my custom dashboard?

1 Like

Welcome to the OpenAI developer community @mahsanr44.

The correct way to programmatically retrieve usage information is through the usage API.

You’ll also need to create an Admin key to access the usage API.

1 Like