HTTP API

Everything the dashboard shows is a plain JSON endpoint you can build on. When auth is locked, the /api/* read endpoints require a session cookie; /api/track also accepts a project gateway key.

Proxy routes

RouteNotes
/p/<project>/<provider>/…Proxy a call, grouped under a project
/k/<key>/<provider>/…Proxy under auth - the key sets the project
/<provider>/…Proxy with x-aicc-project header (or “default”)

Data endpoints

Method + pathReturns
GET /health{ ok, name, version, uptimeMs }
GET /api/metaversion, branding, currency, providers, record count
GET /api/stats?range=7d&project=xtotals, timeseries, by-project / by-model / by-provider
GET /api/requests?limit=100&errorsOnly=1&q=gptrecent requests (newest first)
GET /api/projectsknown projects with totals
GET /api/fxcurrent display currency + exchange rates
GET /api/eventsServer-Sent Events - live request feed
GET /api/traces?range=7dsessions grouped by trace id (newest first)
GET /api/trace?id=…the ordered call timeline for one trace
GET /api/prompts?range=7dper prompt+version cost, latency and error rate
GET /api/models?range=7dmodel comparison (effective $/1M tok, p50/p95, error rate)
GET /api/anomalies?range=30drule-based cost-spike / error-burst flags
GET /api/alertsactive alerts + budgets (spend vs limit) + thresholds
POST /api/trackingest external usage (see below)
POST /api/admin/budgetadmin: set a project budget { project, monthlyUsd, alertAtPct }
DELETE /api/records?simulated=1remove demo records (admin; drop the query to wipe all)

Requests may carry x-aicc-trace, x-aicc-prompt and x-aicc-prompt-version headers (or the same fields in a /api/track body) to power the Traces and Prompts views. See Traces, prompts & budgets.

range accepts 1h · 24h · 7d · 30d · 90d · all, or explicit from/to epoch-ms.

POST /api/track

Report usage the proxy can't see. Cost is computed for you if you omit costUsd. Send one object or an array (up to 1000 records per call).

bash
curl -X POST http://localhost:4321/api/track \
  -H "Content-Type: application/json" \
  -d '{
    "project": "nightly-job",
    "provider": "openai",
    "model": "gpt-4o",
    "tokensIn": 52000,
    "tokensOut": 9000,
    "latencyMs": 820
  }'
response
{ "saved": 1 }

Not just LLMs: track any AI spend

This is the first-class path for costs that never pass through the proxy - speech-to-text, TTS, telephony minutes, image generation, embeddings run elsewhere, batch jobs. Three fields make it composable:

a voice-agent turn: STT minutes + TTS characters joined to the LLM's trace
curl -X POST http://localhost:4321/api/track \
  -H "Content-Type: application/json" \
  -d '[
    { "project": "voice-agent", "provider": "stt", "model": "streaming-stt",
      "trace": "call-8123", "costUsd": 0.0062, "latencyMs": 240 },
    { "project": "voice-agent", "provider": "tts", "model": "neural-tts",
      "trace": "call-8123", "costUsd": 0.0031 },
    { "project": "voice-agent", "provider": "telephony", "model": "sip-minutes",
      "trace": "call-8123", "costUsd": 0.0140, "ts": 1783605600000 }
  ]'

Example: pull today's spend

bash
curl -s "http://localhost:4321/api/stats?range=24h" \
  | python3 -c 'import json,sys; print("$%.2f" % json.load(sys.stdin)["totals"]["costUsd"])'