Every month I got surprised by my OpenAI bill.
Not by a lot — but enough that I'd open the usage dashboard, squint at a chart, try to remember which project burned all those tokens, and give up. The dashboard shows totals. It doesn't help you understand which project cost the most, which model was doing the work, or whether that refactoring session with GPT-4 was actually cheaper than Claude.
So I built AICostTracker — a local CLI that logs API calls and shows a cost breakdown by project and model.
How it works
Log a call after you make it:
aicost log myapp gpt-4o 1500 800 "generated README"
aicost log agentspec claude-3.5-sonnet 2000 1200 "test run"
Then see what you spent:
aicost summary
Output:
AI Cost Tracker — Summary
══════════════════════════════════════════════════
Total entries: 2
Total cost: $0.0358
Input tokens: 3,500
Output tokens: 2,000
By Project:
──────────────────────────────────────────────────
myapp $ 0.0118 1 calls
agentspec $ 0.0240 1 calls
By Model:
──────────────────────────────────────────────────
gpt-4o $ 0.0118 1 calls
claude-3.5-sonnet $ 0.0240 1 calls
Why local-first?
I didn't want another SaaS with an account and a dashboard. The data lives in ~/.aicost/usage.jsonl — one JSON line per call, greppable, portable, yours.
Pricing is baked in for OpenAI (gpt-4o, o1, gpt-4-turbo, gpt-3.5), Anthropic (claude-3.5-sonnet, claude-3-opus, haiku), Google (gemini-1.5), and local/Ollama models (cost: $0).
Install
npm install -g @ozperium/aicost-tracker
aicost log myproject gpt-4o 1000 500 "first entry"
aicost summary
What's next
The obvious next step is automatic logging — a wrapper that intercepts API calls so you don't have to log manually. For now, manual logging is good enough to surface the patterns that matter.
If you use multiple AI APIs and want to know where your money's actually going, give it a try.
GitHub: https://github.com/Ozperium/aicost-tracker
Also in the stack: AgentSpec for testing AI agent behavior, and quota for tracking rate limits before they stop you.
Top comments (0)