Cost Tracking

Understand how Grafient tracks and visualizes your AI costs.

How It Works

Grafient pulls cost data from your connected providers in two ways:

On-Demand Sync

When you visit the dashboard or click Force Sync on an integration, we fetch fresh data from the provider's API for the current period. This gives you real-time visibility without waiting for scheduled updates.

Daily Cron Sync

A scheduled job runs every day at 6 AM UTC to pull the previous day's final cost data for all active integrations. This ensures we never miss data for days you don't visit the dashboard.

Dashboard Overview

The main dashboard shows:

  • Summary Cards: Total spend, daily average, most expensive model, and month-over-month change
  • Cost Chart: An area chart showing spend over time, stacked by provider
  • Provider Cards: Per-integration cards showing cost, token count, and sync status

Time Periods

Use the period selector in the top bar to view:

  • 7d: Last 7 days
  • 30d: Last 30 days
  • 90d: Last 90 days

Cost Breakdown

The Breakdown page provides a sortable table with per-model cost details, including:

  • Model name and provider
  • Input/output/cached token counts
  • Total cost in USD

Data Storage

Cost data is stored as daily snapshots in the daily_costs table. Each record includes:

  • The date
  • Total cost in USD
  • Model-level breakdown (JSON)
  • Token usage counts (JSON)
  • Raw API response for debugging