# ── NVIDIA NIM ──────────────────────────────────────────────────────── NIM_API_KEY= NIM_API_URL=https://integrate.api.nvidia.com # ── Database ─────────────────────────────────────────────────────────── # Local dev: a plain Postgres URL. # Production (Supabase free tier) — use the RIGHT endpoint per consumer: # • Collector + `prisma migrate deploy` → SESSION pooler / direct (port 5432): # postgresql://postgres.:@aws-0-.pooler.supabase.com:5432/postgres # • Web app (Cloudflare Worker) → not read from here. It connects through the # HYPERDRIVE binding (cloudflare.config.ts), which points at that same # session pooler. `npm run dev` falls back to this DATABASE_URL. DATABASE_URL="postgresql://user:pass@host:5432/nim_stats?schema=public" # ── Internal API token ──────────────────────────────────────────────── # Locks down the non-browser API routes (anomalies, quota, overview, models, # providers). Unset = open (fine for local dev). MUST be set in production — # send it as `Authorization: Bearer ` to reach those routes. # Generate: `openssl rand -hex 32` INTERNAL_API_TOKEN= # ── Cache revalidation (collector only) ─────────────────────────────── # Public origin of the deployed site, e.g. https://nimstats.aathil.com. The # collector POSTs {REVALIDATE_URL}/api/internal/revalidate every other probe # cycle (SITE_REFRESH_CYCLES) and whenever models joined or left; that is what # refreshes the site's ISR pages and cached queries (they no longer run on a # short timer). Needs INTERNAL_API_TOKEN to match the deployment's. Unset = # skipped; the site falls back to a 30-min safety-net TTL. # The GitHub workflows default this to the production origin. REVALIDATE_URL= # ── Probe scheduler (prod) ──────────────────────────────────────────── # The probe cadence is driven by a Cloudflare Worker cron (cloudflare/cron-worker) # that dispatches the GitHub Actions workflow directly. Its GitHub PAT lives as a # Cloudflare Worker Secret named GH_DISPATCH_TOKEN — NOT here and NOT on the web Worker. # GitHub's hourly `schedule:` in .github/workflows/probe.yml is the fallback. # ── Upstash Redis (NOT required) ────────────────────────────────────── # Currently unused — the probe rate limiter is in-process. Left here only as a # future hook; safe to omit entirely in production. # UPSTASH_REDIS_REST_URL=https://your-redis.upstash.io # UPSTASH_REDIS_REST_TOKEN=your-token # ── Tuning knobs ────────────────────────────────────────────────────── PROBE_MAX_RPM=30 # outbound probe cap (NVIDIA NIM free tier = 40 rpm; keep margin) PROBE_CONCURRENCY=6 # max in-flight probes (start rate still capped by PROBE_MAX_RPM) SYNC_INTERVAL_MS=21600000 # 6 h between model-registry syncs RETENTION_DAYS=30 # prune samples older than this # ── Worker schedules (node-cron — LOCAL dev only) ───────────────────── # These drive the always-on `npm run worker`. In production the worker doesn't # run; the Cloudflare cron Worker dispatches GitHub Actions, which invokes # `scripts/probe-once.ts` (probe every 10 min, maintenance daily) — see # .github/workflows/ and cloudflare/cron-worker/. 10 min keeps ModelSample well # inside Supabase's free 500 MB (~30 MB at ~34 models × 30-day retention). # # The UI refresh cadence is derived from this interval in lib/config/cadence.ts — # if you change the probe cron, change PROBE_INTERVAL_S to match. PROBE_WORKER_CRON=* * * * * # probe every active endpoint each minute MODEL_REGISTRY_SYNC_CRON=0 */6 * * * # re-sync the NIM model registry every 6 h MAINTENANCE_CRON=0 3 * * * # prune old samples + retire dead models daily # Operational thresholds (override defaults without code change). Rates are # fractions of the last ~20 probes; TTFT is the median of successful probes, in ms. TTFT_BUSY_MAX=3000 ERROR_RATE_HEALTHY_MAX=0.05 ERROR_RATE_BUSY_MAX=0.5 TIMEOUT_RATE_BUSY_MAX=0.5