Installation
Install @edwinfom/ai-guard with your preferred package manager:
npm install @edwinfom/ai-guardpnpm add @edwinfom/ai-guardyarn add @edwinfom/ai-guardbun add @edwinfom/ai-guardRequirements
- Node.js ≥ 18 (uses native
fetch,structuredClone, etc.) - TypeScript 5.4+ (recommended for full type inference)
Optional Peer Dependency
If you want to use Zod schema validation (highly recommended):
npm install zodZod is completely optional — you can use a custom validator function instead. See Custom Adapter.
Zero Mandatory Runtime Dependencies
The only runtime dependency is jsonrepair — a battle-tested JSON repair library. Everything else is built-in.
Tree-Shakeable Sub-paths
Import only what you need — zero dead code in your bundle:
import { redactPII, detectPII } from '@edwinfom/ai-guard/pii';
import { repairAndParse, repairJSON } from '@edwinfom/ai-guard/schema';
import { detectInjection } from '@edwinfom/ai-guard/injection';
import { buildUsage, calculateCost } from '@edwinfom/ai-guard/budget';See Tree-Shakeable Sub-paths for the full list.