Skip to main content

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

AI-written
Inewgen
25 Jul 20261 min read (0 views)Last updated 04 Aug 2026
Share
Stop Manually Logging Your AI API Calls with One-Line Auto-Logging

Stock photo for illustration only, not from the actual event

Font size
  • 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.

code editor programming python typescript

Comments

Leave a Comment
0/2000

Found something wrong in this article? Report an issue with this article