← All modules
analytics

Cloud Costs

Live

Track cloud costs across GCP, AWS, DigitalOcean, and Azure with budget alerts.

event.type === "cost" modules/costs
Overview

What Cloud Costs does

Costs aggregates spending across GCP, AWS, DigitalOcean, Azure, Turso, and Anthropic into a single ledger. The plugin polls each provider's billing API on an interval (default hourly) and emits a `cost` event per metric — rows read, rows written, storage bytes, API calls, dollars. Every event carries a billing period (`YYYY-MM`) so daily aggregations are a `GROUP BY` away.

Budgets and alerts are first-class. Set a monthly cap per provider, per project, or globally; the dashboard fires an alert when projected spend crosses the threshold. Custom providers — your own SaaS bills, your own databases — drop in via the `custom` provider type with a `fetchUsage()` callback you write once.

Wire payload

Same shape, three syntaxes

The wire protocol is plain HTTP, plain JSON, HMAC-SHA256. The TypeScript tab uses the SDK; the cURL tab is the raw HTTP equivalent; the Python tab shows the preview SDK shape.

import { createCuittyClient } from "@cuitty/sdk";
import { costsPlugin } from "@cuitty/sdk/plugins/costs";

const cuitty = createCuittyClient({
  portalUrl: "https://app.cuitty.com",
  projectId: process.env.CUITTY_PROJECT_ID!,
  apiKey: process.env.CUITTY_API_KEY!,
});
cuitty.use(costsPlugin());
cuitty.start();

cuitty.use(costsPlugin({
  providers: [
    { id: "turso-prod", type: "turso", apiToken: TOKEN, organizationId: ORG },
    { id: "anthropic", type: "anthropic", apiKey: ANTHROPIC_KEY },
  ],
  pollInterval: 3_600_000, // hourly
}));
SDK plugin

Drop-in plugin

@cuitty/sdk/plugins/costs
import { costsPlugin } from "@cuitty/sdk/plugins/costs";

cuitty.use(costsPlugin({
  providers: [{ id: "turso-prod", type: "turso", apiToken: TOKEN, organizationId: ORG }],
}));
Storage

Database schema

Excerpt from modules/costs/schema.sql. One libSQL file per module — back it up with cp.

CREATE TABLE IF NOT EXISTS costs (
  id INTEGER PRIMARY KEY AUTOINCREMENT,
  date TEXT NOT NULL,
  amount REAL NOT NULL,
  currency TEXT NOT NULL DEFAULT 'USD',
  cost_type TEXT NOT NULL,
  resource_id INTEGER REFERENCES resources(id),
  billing_period TEXT NOT NULL,
  created_at INTEGER DEFAULT (unixepoch())
);

Related modules