cd /news/developer-tools/i-built-a-local-first-cli-to-track-wโ€ฆ ยท home โ€บ topics โ€บ developer-tools โ€บ article
[ARTICLE ยท art-71098] src=dev.to โ†— pub= topic=developer-tools verified=true sentiment=ยท neutral

I built a local-first CLI to track what I'm actually spending on AI APIs

A developer built AICostTracker, a local-first CLI tool that logs API calls to OpenAI, Anthropic, Google, and Ollama models and provides a cost breakdown by project and model. The tool stores data in a local JSONL file, avoiding the need for a SaaS dashboard.

read2 min views1 publishedJul 23, 2026

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.

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

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).

npm install -g @ozperium/aicost-tracker
aicost log myproject gpt-4o 1000 500 "first entry"
aicost summary

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.

โ”€โ”€ more in #developer-tools 4 stories ยท sorted by recency
โ”€โ”€ more on @openai 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain โ€” perfect for shipping the agent you just read about.

$git push zahid main
โ†’ Live at https://your-agent.zahid.host โœ“
Get free account โ†’ Pricing
from โ‚ฌ0/mo ยท no card required
LIVE [news/i-built-a-local-firsโ€ฆ] indexed:0 read:2min 2026-07-23 ยท โ€”