Sayay

npm @carloscortezcloud/sayay-guard · PyPI sayay

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.

npm — TypeScript / Workers
npm install @carloscortezcloud/sayay-guard
pip — Python (Strands, LangChain, CrewAI)
pip install sayay

Features

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 — TypeScript

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 cost

Usage — Python

from sayay import SayayGuard, MemoryStorage

guard = SayayGuard(
    storage=MemoryStorage(),
    budget={'dailyUsd': 5.0, 'monthlyUsd': 50.0},
)

# Before each LLM call:
decision = await guard.check('user-123', 0.01)
# → { 'action': 'allow', 'remaining': 4.99 }

# After each LLM call:
await guard.record('user-123', 0.003)
GitHub →npm →PyPI →Demo →

When to Use Sayay

Works With

Tinkuy AgentStrands Agents (via Plugin)Any LLM frameworkRedis / KV / D1 storage