LLM Spend TripwireChecklistCodeHosted waitlist

wrangler.toml

Commit 01f96e7. All files · Download the tarball.

# LLM Spend Tripwire: deploy this to YOUR Cloudflare account. See README.md.
name = "llm-spend-tripwire"
main = "src/index.js"
compatibility_date = "2026-11-01"
workers_dev = true  # needed only for the optional /test-alert and /dry-run endpoints

# Check every 5 minutes. Anthropic's usage data usually lands within ~5 minutes and the API supports
# polling once per minute, so "* * * * *" also works if you want faster checks.
[triggers]
crons = ["*/5 * * * *"]

# One small row of state (baseline sums, seen keys/models, cooldowns). Created on first run.
[[d1_databases]]
binding = "DB"
database_name = "llm-spend-tripwire"
# No database_id: `wrangler deploy` (and the Deploy to Cloudflare button) create the database for you.
# https://developers.cloudflare.com/workers/wrangler/configuration/#automatic-provisioning

[vars]
SPIKE_MULTIPLIER = "5"          # alert when a key's busiest recent minute is more than N x its average
BASELINE_MINUTES = "360"        # how far back the average looks (60 to 10080)
MIN_TOKENS_PER_MINUTE = "50000" # ignore spikes smaller than this many tokens in one minute
COOLDOWN_MINUTES = "60"         # repeat the same spike/off-hours alert at most this often
TIMEZONE = "UTC"                # IANA name, e.g. "America/New_York"
WORK_HOURS = ""                 # e.g. "08:00-19:00"; empty turns off-hours alerts off
WORK_DAYS = "1-5"               # ISO weekdays, 1 = Monday
OFF_HOURS_MIN_TOKENS = "1000"   # per minute, before off-hours use counts
ALERT_NEW_KEYS = "true"
ALERT_NEW_MODELS = "true"
WATCH_KEY_LIST = "true"         # also list active API keys, to catch new keys before they are used
PRICES_JSON = ""                # optional overrides, USD per million tokens; see README
# Secrets (set with `wrangler secret put`): ANTHROPIC_ADMIN_KEY, ALERT_WEBHOOK_URL, TEST_SECRET (optional)