How to track API usage and cost by API key?

You can use the command req Get to
https://api.openai.com/v1/dashboard/billing/usage?start_date=2023-05-01&end_date=2023-05-31

The result returned at the variable total_usage/100 is the cost of credit you have used from start_date to end_date

3 Likes