My company will use different API key for different AI-enabled applications/features/engineering teams. We’d like to track usage and cost by API key. Is that a way to track API usage and cost by API keys?
It seems right now the usage tracking is by organization only.
It would be fine if we need to track it as middleware when hitting OpenAI API. Just want to make sure I am not missing a hidden feature.
I have the same requirement. There are multiple applications that are using the key and tracking usage per key would help identify utilization across apps.
What we do is log a token identifier, and the response model name and tokens used, for each API request, into our log/metrics/tracing/observability system.
We then sum this up in a worksheet with a simple query.
Observe Inc has a simple OpenAI integration: What's New: OpenAI App!
However, you’ll still need to add instrumentation to your own code to log out the model/token counts, and write a query to parse that back in and sum it up.
(Observe is an enterprise software suite; there’s no free trial or open source version; if your volumes are low, doing the summary in Python or SQL or somesuch might be tractable as an alternative.)