Docs

Five minutes: point, tag, see the money.

Log a call

curl -X POST "localhost:8080/v1/log?workspace=acme" \
  -H "Authorization: Bearer <PROMPTLEDGER_API_KEY>" \
  -H "X-Feature: support-reply" \
  -H 'Content-Type: application/json' \
  -d '{"model":"gpt-4o-mini","input_tokens":1200,"output_tokens":300}'
# {"ok":true,"feature":"support-reply","cost_usd":0.00036,
#  "budget_breaches":[],
#  "note":"estimate; provider invoice is source of truth"}

See the dashboard

curl -H "Authorization: Bearer <key>" \
  "localhost:8080/dashboard?workspace=acme"
# {"workspace":"acme","month_to_date_usd":12.3456,
#  "by_feature":[{"feature":"support-reply","calls":420,"usd":8.12,...}],
#  "budget_breaches":[...],"anomalies":[...],
#  "note":"costs are estimates; provider invoice is source of truth"}

Set budgets (operator)

python3 -c "
import ledger
conn = ledger.connect('promptledger.db')
# alert-only budget
ledger.set_budget(conn, workspace='acme', feature='support-reply', cap_usd=50.0)
# hard cap: refuse log records over budget (Scale+)
ledger.set_budget(conn, workspace='acme', feature='agent-loop',
                  cap_usd=100.0, hard_cap=True)
# workspace-wide cap
ledger.set_budget(conn, workspace='acme', feature='*', cap_usd=500.0)
"

Breaches post to Slack when SLACK_WEBHOOK is set; otherwise they're logged.

Anomaly detection

python3 -c "
import ledger
conn = ledger.connect('promptledger.db')
print(ledger.anomalies(conn, 'acme'))
# [{"feature":"agent-loop","today_usd":41.2,
#   "baseline_daily_avg_usd":2.1,"spike_factor":19.6}]"

Flags features whose spend today exceeds 3× their 7-day daily average (min $5/day).

Health

curl localhost:8080/health
# {"ok":true,"service":"promptledger"}