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, model. https://platform.openai.com/docs/api-reference/usage
OpenAI has a new Usage API that lets you track API usage and costs programmatically.
Monitor tokens by minute/hour/day
Filter usage by API key, project ID, user ID, model, and more
Check daily spend via the Costs endpoint
Nice! Lots of people have been asking for this for a while now!
Thanks also for killing off the “other models” idea in “usage”, in which the billing for everything useful was clustered for obfuscation…
Models by name are back.
@edwinarbus looks like API keys require a new api.usage.read
scope in order to use this new Costs API. I can’t seem to enable this scope for any new keys I create.
Is there something that needs to be enabled on an account in order to use this new API?
Example request:
curl "https://api.openai.com/v1/organization/costs?start_time=1730419200&limit1" -H "Authorization: Bearer [api-key]"
Example response:
{
"error" : {
"message": "You have insufficient permissions for this operation. Missing scopes: api.usage.read. […]",
"type": "servier_error",
"param": null,
"code" : null
}
}
In case anyone else is hitting this, the new /costs
API requires an admin key, not an API key.
This topic was automatically closed after 11 days. New replies are no longer allowed.