Although you can calculate costs by the token consumption returned by API calls when calling the models. It gives you prompt_tokens and completion_tokens separately.
Or are trying to create a tool for API key management/billing optimization?
@cdonvd0s is correct that there is no API for that purpose specifically.
You would need to implement a gateway which will enable you to track the metrics.
If you are trying to build an anomaly detection tool for users to get notified about any unusual usage of API keys (great idea btw) you can use the following workflow.
Steps
Description
Tools/Links
1
Use a web scraping service to download the usage data