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
- The gateway buffers the request body (up to 16 MB).
- Pattern matchers scan text for known secret types and injection heuristics.
- Each match is assigned an action:
block,redact, orwarn. - Blocked requests return a
content_policy_violationerror and are recorded in usage events with statusdlp_blocked. - Redacted requests continue, with matched secrets replaced by placeholders.
- 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 variableALLTERNIT_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 headerx-allternit-dlp-response: redacted is included.
Error codes
Related pages
- Security overview — security model and controls
- Inference hooks — custom pre/post-processing hooks
- Admin gateway — LLM gateway administration endpoints