Stop Manually Logging Your AI API Calls with One-Line Auto-Logging
Developers share a solution to forget-me-not costs of OpenAI and Anthropic API calls with a seamless, automated track() function

Stock photo for illustration only, not from the actual event
- Using AI APIs always accumulates costs, but manual logging is often neglected and leads to incomplete data.
- Version v0.1.2 adds the track() function to wrap OpenAI and Anthropic request-response handlers for automated logging.
- The system pulls data from the usage field and immediately triggers the logUsage() function without adding latency.
- It supports project-based tagging, such as { project: 'myapp' }, to clearly categorize usage by category.
Every time you call an AI API, costs are inevitably incurred. However, if developers do not continuously check the dashboard after a session ends, they have almost no way of knowing which project or model is actually the culprit behind soaring bills. Even though tools like AICostTracker used to offer commands like aicost log myapp gpt-4o 1500 800 to record usage data, in reality, no developer does this consistently because they either forget or get caught up in coding and plan to do it later. As a result, the recorded data ends up patchy, and the final summary becomes useless.
To solve this issue, version v0.1.2 introduces the track() function, which acts as a wrapper for both OpenAI and Anthropic clients, making it easy for developers to track costs immediately without relying on old methods.

Found something wrong in this article? Report an issue with this article
Comments
Leave a Comment