AI GatewayReviewed 2026-01-13

Rewrite instead of refuse: improve LLM UX safely

Use AI gateway guardrails to rewrite sensitive outputs instead of refusing, with policy reasons and audit tags.

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.

Definition

Rewrite instead of refuse: improve LLM UX safely

Rewrite instead of refuse is a guardrail pattern that replaces unsafe outputs with compliant alternatives while preserving intent.

Why it matters
  • Reduce churn caused by inconsistent refusals.
  • Keep policy outcomes predictable and auditable.
  • Provide safer alternatives instead of a dead end.
How it works
  1. 01Set response_pattern to rewrite and enable rewrite_instead_of_refuse.
  2. 02Define denylist topics and flagged categories that trigger the rewrite.
  3. 03Inspect reason_code and triggered_categories for compliance proof.
Runnable cURL snippet
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"
  }'
Example policy JSON
{
  "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" }
}
Before and after
Before (provider refusal)
Assistant: "I can't help with that."
After (Policy Gateway rewrite)
Assistant: "I can help you secure your account and reset credentials safely."
decision: rewrite
reason_code: REWRITE

Run the Policy Gateway simulator

Try rewrite mode on sample scenarios and inspect the decision metadata.

Run a simulation
FAQ

Frequently asked questions.

Can I combine rewrite and redaction?

Yes. Enable redaction to scrub sensitive spans even when a rewrite is returned.

Does rewrite work with allowlists?

If allowlist rules are configured and nothing matches, the policy still refuses by design.