Skip to content

7alexhale5-rgb/api-cost-dashboard

Repository files navigation

API Cost Dashboard πŸ’°

Zero-cost, self-hosted API cost tracking for bootstrapped founders.

Stop burning money on expensive monitoring tools. Track your Claude API, Perplexity, Firecrawl, and other API costs with a beautiful local dashboard - no monthly fees, no data leaving your machine.

Dashboard Overview

Why This Exists

You're building with AI APIs. Costs can spike without warning. Expensive monitoring tools like Datadog ($500+/mo) are overkill. This dashboard gives you enterprise-grade cost tracking for $0/month using tools you already have.

Features ✨

  • πŸ“Š Real-time cost tracking across multiple API providers
  • 🚨 Smart alerts via Telegram when budgets are exceeded
  • πŸ” Cache anomaly detection (catches expensive cache writes before they burn your budget)
  • πŸ“ˆ Historical trends with 30-day charts
  • πŸŒ™ Dark mode (because we code at night)
  • πŸ“± Mobile responsive
  • ⚑ Auto-refresh every 60 seconds
  • πŸ†“ Completely free - uses SQLite + local Next.js

Quick Start πŸš€

Prerequisites

  • Node.js 18+
  • SQLite3
  • A Unix-like system (macOS or Linux)

Installation

  1. Clone the repo
git clone https://github.com/7alexhale5-rgb/api-cost-dashboard.git
cd api-cost-dashboard
npm install
  1. Set up the data collector
# Create the data directory
mkdir -p ~/.api-usage/logs

# Copy the collection script
cp scripts/setup/collect.sh ~/.api-usage/
chmod +x ~/.api-usage/collect.sh

# Copy the schema
cp scripts/setup/schema.sql ~/.api-usage/
sqlite3 ~/.api-usage/usage.db < ~/.api-usage/schema.sql

# Copy the config template
cp scripts/setup/config.json ~/.api-usage/

# Set up your API keys
echo 'export ANTHROPIC_ADMIN_KEY="sk-ant-admin-..."' >> ~/.config/api-keys.env
echo 'export PERPLEXITY_API_KEY="pplx-..."' >> ~/.config/api-keys.env
  1. Set up the cron job (collects data every 15 minutes)
# macOS (launchd)
cp scripts/setup/com.api-usage-collect.plist ~/Library/LaunchAgents/
launchctl load ~/Library/LaunchAgents/com.api-usage-collect.plist

# Linux (systemd)
sudo cp scripts/setup/api-usage-collect.service /etc/systemd/system/
sudo systemctl enable api-usage-collect.timer
sudo systemctl start api-usage-collect.timer
  1. Start the dashboard
npm run dev

Open http://localhost:3400

Supported Providers πŸ”Œ

  • βœ… Anthropic (Claude API via Admin API)
  • βœ… Perplexity (sonar-pro, sonar-deep-research)
  • βœ… Firecrawl (credit tracking)
  • πŸ”œ OpenAI (coming soon)
  • πŸ”œ Google AI (Gemini)
  • πŸ”œ Voyage AI

Want to add a provider? See CONTRIBUTING.md

Screenshots πŸ“Έ

Overview Dashboard

Overview Cost summary, trends, budget alerts, and token usage at a glance

Alert History

Alerts Cache anomaly detection caught a $36 Haiku spike before it got worse

Emergency Response

Emergency Detect runaway cron jobs and kill them before they drain your budget

How It Works πŸ”§

β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  API Providers      β”‚
β”‚  (Claude, etc)      β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚
           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  collect.sh         β”‚
β”‚  (runs every 15min) β”‚
β”‚  - Polls Admin APIs β”‚
β”‚  - Calculates costs β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚
           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  SQLite Database    β”‚
β”‚  ~/.api-usage/      β”‚
β”‚  usage.db           β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
           β”‚
           β–Ό
β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
β”‚  Next.js Dashboard  β”‚
β”‚  localhost:3400     β”‚
β”‚  - Charts & Alerts  β”‚
β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

Configuration βš™οΈ

Edit ~/.api-usage/config.json:

{
  "providers": {
    "anthropic": {
      "daily_limit_usd": 5.00,
      "monthly_limit_usd": 50.00,
      "alert_threshold_pct": 80
    },
    "perplexity": {
      "daily_limit_usd": 3.00,
      "monthly_limit_usd": 20.00
    }
  },
  "retention_days": 90,
  "telegram": {
    "enabled": true,
    "bot_token": "YOUR_BOT_TOKEN",
    "chat_id": "YOUR_CHAT_ID"
  }
}

Budget Thresholds πŸ’΅

Default limits (customize in config):

Provider Daily Warning Daily Critical Monthly Cap
Anthropic $2.00 $5.00 $50.00
Perplexity $1.00 $3.00 $20.00
Combined $3.00 $8.00 $70.00

Tech Stack πŸ› οΈ

Dashboard:

  • Next.js 14 (App Router)
  • TypeScript
  • Tailwind CSS
  • Recharts
  • better-sqlite3
  • React Query

Data Collection:

  • Bash scripts
  • SQLite
  • cron/launchd

Why Not Just Use X? πŸ€”

Datadog? - $500+/mo, overkill for indie devs CloudZero? - $500-2000/mo, great but expensive Langfuse? - Focused on traces, not cost dashboards DIY spreadsheet? - No alerts, no trends, manual work

This tool gives you 90% of the features for 0% of the cost.

Roadmap πŸ—ΊοΈ

  • OpenAI integration
  • Google AI (Gemini) support
  • Cost forecasting (ML-based)
  • Slack/Discord alerts
  • Docker image
  • Multi-workspace support
  • Export to CSV
  • Budget recommendations (AI-powered)

Contributing 🀝

We love contributions! See CONTRIBUTING.md

Ways to contribute:

  • πŸ› Report bugs
  • πŸ’‘ Suggest features
  • πŸ”Œ Add new API providers
  • πŸ“– Improve docs
  • 🎨 Design improvements

License πŸ“„

MIT License - see LICENSE

Credits πŸ‘

Built by @7alexhale5-rgb for the bootstrapped founder community.

Inspired by the need to track runaway Haiku cache writes that were burning $36/day. πŸ”₯

Star History ⭐

If this saved you money, give it a star! It helps other founders find it.


Made with β˜• by a vibe coder who got tired of surprise API bills

About

Zero-cost, self-hosted API cost tracking for bootstrapped founders

Topics

Resources

License

Contributing

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors