Validate AI-generated outputs against hard, deterministic rules — schema, arithmetic, consistency — and fix violations with bounded LLM calls.
Your AI outputs need a warranty. Guardail provides deterministic validation that catches errors before they reach production.
Validate JSON structure against your schema. Required fields, correct types, no unexpected keys — deterministically checked.
Catch math errors automatically. Subtotal + VAT ≠ Total? Line items don't sum? We flag it.
Detect hallucinations. Numbers, dates, and entities in the output should exist in the source input.
Optionally fix violations with LLM calls. BYOK for unlimited, or use our capped fallback token.
Validation runs locally on Cloudflare's edge. No LLM round-trip needed for warranty checks.
Warranty checks are free. Repair is BYOK or quota-capped. Zero surprise bills.
One POST request. Three validation rules. Optional repair.
POST your AI output along with the original input and your expected schema.
Guardail checks structure, arithmetic, and consistency against objective rules.
If validation fails and repair is enabled, an LLM attempts to fix the violations.
Receive validated output with status (pass/failed/repaired) and any warnings.
One endpoint. Clear request/response format.
curl -X POST "https://guardail-api.workers.dev/v1/guard" \
-H "Content-Type: application/json" \
-H "Authorization: Bearer YOUR_SECRET" \
-d '{
"input": "Invoice INV-001 subtotal £83.33 VAT £16.67 total £100",
"output": {
"invoice_number": "INV-001",
"subtotal": 83.33,
"vat": 16.67,
"total": 100
},
"schema": {
"invoice_number": "string",
"subtotal": "number",
"vat": "number",
"total": "number"
},
"policy": {
"rules": ["structure", "arithmetic"],
"repair": false
}
}'
// Response
{
"ok": true,
"status": "pass",
"output": { ... },
"violations": [],
"warnings": [],
"meta": {
"request_id": "abc123",
"latency_ms": 12
}
}
Three objective rules that catch real problems.
| Rule | Type | What It Checks |
|---|---|---|
structure |
Error | JSON validity, schema match, required fields, correct types, no extra keys (strict mode) |
arithmetic |
Error | subtotal + vat = total, sum(line_items.amount) = total |
consistency |
Warning | Numbers, dates, and entities in output should exist in input |