Policy Gateway Integration: request/response contract
The exact contract for /policy/chat/completions: required fields, optional headers, and decision metadata.
This is the contract for integrating Policy Gateway. If you already send OpenAI-style chat completions, you can send Policy Gateway requests with one endpoint swap and a policy_id.
Use the optional headers to unlock quotas, budgets, and rollout targeting for production traffic.
curl https://api.abliteration.ai/policy/chat/completions \
-H "Authorization: Bearer $POLICY_KEY" \
-H "Content-Type: application/json" \
-H "X-Policy-User: user-12345" \
-H "X-Policy-Project: support-bot" \
-H "X-Policy-Target: support-bot" \
-d '{
"model": "abliterated-model",
"messages": [{ "role": "user", "content": "Summarize our refund policy." }],
"policy_id": "policy-gateway"
}'Request contract
Send a standard chat completion payload with a policy_id. Optional headers allow per-user quotas, per-project budgets, and rollout targeting.
| Field | Details |
|---|---|
| Endpoint | POST /policy/chat/completions |
| Auth | Authorization: Bearer <policy key> |
| Required fields | model, messages, policy_id |
| Optional but recommended |
X-Policy-User or policy_user (quotas + per-user audit)X-Policy-Project or policy_project_id (budgets + per-project audit)X-Policy-Target or policy_target (rollout targeting) |
Response contract
Responses include the model output plus policy metadata for audits and debugging. The policy block mirrors the Policy Gateway console fields.
{
"id": "chatcmpl-policy-123",
"object": "chat.completion",
"created": 1735958400,
"model": "abliterated-model",
"choices": [
{
"index": 0,
"message": {
"role": "assistant",
"content": "Here is a brief summary of your refund policy."
},
"finish_reason": "stop"
}
],
"usage": {
"prompt_tokens": 18,
"completion_tokens": 12,
"total_tokens": 30
},
"policy": {
"policy_id": "policy-gateway",
"decision": "rewrite",
"effective_decision": "rewrite",
"reason_code": "REWRITE",
"triggered_categories": ["self-harm/intent"],
"allowlist_hits": ["refund policy"],
"denylist_hits": [],
"rollout_mode": "enforced",
"enforced": true,
"policy_target": "support-bot",
"policy_user": "user-12345",
"project_id": "support-bot"
}
}Policy decision flow (deterministic)
Policy Gateway follows a fixed evaluation order so outcomes are predictable and testable.
- Parse request metadata (policy_id, policy_user, policy_project_id, policy_target).
- Apply allowlist and denylist topic rules to the user request.
- Apply flagged category triggers from moderation.
- Determine decision from the response pattern (rewrite/summary/escalate/refuse).
- Apply sensitive-span redaction to the response (if enabled).
- Emit decision, reason_code, triggered_categories, and audit tags.