Overview

The Allternit LLM gateway includes built-in Data Loss Prevention (DLP) middleware that scans request and response bodies for secrets, credentials, and prompt-injection attempts. DLP runs after virtual-key authentication and rate limiting, but before the budget check and provider routing, so sensitive data is caught before any spend occurs.

How DLP works

  1. The gateway buffers the request body (up to 16 MB).
  2. Pattern matchers scan text for known secret types and injection heuristics.
  3. Each match is assigned an action: block, redact, or warn.
  4. Blocked requests return a content_policy_violation error and are recorded in usage events with status dlp_blocked.
  5. Redacted requests continue, with matched secrets replaced by placeholders.
  6. Warned requests continue, with a warning header returned to the caller.

Built-in secret patterns

Secrets are never logged in plaintext. The gateway records only the pattern id and a SHA-256 hash of the matched bytes.

Injection heuristics

The DLP layer also scores messages for prompt-injection and jailbreak attempts: Default thresholds:

Actions

Configuration

Administrators can manage custom DLP rules through the LLM gateway admin API. The default action for built-in patterns is controlled by the environment variable ALLTERNIT_DLP_DEFAULT_ACTION (block, redact, or warn).

Environment variables

Admin DLP rules

Organization admins can list and update custom rules at /api/v1/gateway/dlp/rules.

List rules

Create or update a rule

Response-side DLP

For non-streaming chat completions, the gateway can also scan the assistant response. When response-side redaction occurs, the header x-allternit-dlp-response: redacted is included.

Error codes