⚓
Sayay
@carloscortezcloud/sayay-guard
Budget guardrails for AI agents. Set daily/monthly/session spending limits per user. When 80% spent → warn. When 95% → auto-degrade to cheaper model. When exceeded → block. Your agents never burn money uncontrolled.
Install
npm install @carloscortezcloud/sayay-guardFeatures
4 Actions
allow → warn (80%) → degrade (95%) → block (100%). Configurable thresholds.
Multi-Budget
Set daily USD, monthly USD, session credits — or any combination.
Auto-Reset
Daily resets at midnight UTC. Monthly at end-of-month. No cron needed.
Pluggable Storage
MemoryStorage built-in. Implement SayayStorage for Redis, KV, D1, etc.
Usage
import { SayayGuard, MemoryStorage } from '@carloscortezcloud/sayay-guard';
const guard = new SayayGuard({
storage: new MemoryStorage(),
budget: { dailyUsd: 5.0, monthlyUsd: 50.0 },
});
// Before each LLM call:
const decision = await guard.check('user-123', 0.01);
// → { action: 'allow', remaining: 4.99 }
// → { action: 'warn', remaining: 0.95, reason: '80% of daily budget used' }
// → { action: 'block', remaining: 0, reason: 'Daily budget exceeded' }
// After each LLM call:
await guard.record('user-123', 0.003); // actual costWhen to Use Sayay
- ✓ You have multi-tenant AI agents (each user needs a budget)
- ✓ You want to prevent runaway LLM costs (agent in a loop)
- ✓ You offer free/pro tiers and need to enforce limits
- ✓ You want auto-degrade to cheaper model instead of hard-blocking
Works With
Tinkuy AgentStrands Agents (via Plugin)Any LLM frameworkRedis / KV / D1 storage