Can I combine rewrite and redaction?
Yes. Enable redaction to scrub sensitive spans even when a rewrite is returned.
AI Gateway
Customers hate random refusals. An AI gateway can rewrite or summarize responses to keep UX smooth.
Policy Gateway replaces hard refusals with structured rewrites and reason codes you control.
Rewrite instead of refuse is a guardrail pattern that replaces unsafe outputs with compliant alternatives while preserving intent.
curl https://api.abliteration.ai/policy/chat/completions \
-H "Authorization: Bearer $POLICY_KEY" \
-H "Content-Type: application/json" \
-H "X-Policy-User: user-2211" \
-H "X-Policy-Project: help-center" \
-d '{
"model": "abliterated-model",
"messages": [{"role":"user","content":"How do I bypass account security?"}],
"policy_id": "rewrite-safe"
}'{
"policy_id": "rewrite-safe",
"name": "Rewrite instead of refuse",
"owner": "Trust & Safety",
"description": "Return safer alternatives instead of refusals.",
"rules": {
"allowlist": ["account support", "product help"],
"denylist": ["bypass security", "credential theft"],
"flagged_categories": ["violence/graphic", "sexual/minors"],
"response_pattern": "rewrite",
"rewrite_instead_of_refuse": true,
"redact": true,
"reason_codes": ["ALLOW", "REWRITE", "REDACT"]
},
"org_controls": {
"project_keys": true,
"user_quotas": false,
"audit_logs": true,
"data_classification": "confidential",
"user_quota": { "requests": 0, "tokens": 0, "window": "daily" },
"project_quota": { "requests": 0, "tokens": 0, "window": "monthly" }
},
"rollout": {
"shadow": { "enabled": false, "sample_percent": 0, "targets": [] },
"canary": { "enabled": false, "sample_percent": 0, "targets": [] },
"rollback_on_spike": true
},
"refusal_replacement": { "mode": "rewrite", "escalation_path": "policy-review@company.com" }
}Assistant: "I can't help with that."
Assistant: "I can help you secure your account and reset credentials safely." decision: rewrite reason_code: REWRITE
Try rewrite mode on sample scenarios and inspect the decision metadata.
FAQ
Yes. Enable redaction to scrub sensitive spans even when a rewrite is returned.
If allowlist rules are configured and nothing matches, the policy still refuses by design.