Project: zer0pii.ai - Enterprise AI Security Gateway & DLP
Version: 1.0.0
Base URL: https://api.zer0pii.com/v1
Providers supported today: OpenAI, Anthropic, Google Gemini. There is currently no support for AWS Bedrock, standalone vLLM, or regional base URLs (eu./us.).
1. Overview
zer0pii.ai operates as a transparent drop-in gateway compatible with the standard OpenAI, Anthropic and Gemini interfaces. To connect, you change only the base URL in your existing SDK:
https://api.zer0pii.com/v1
The gateway scans the outgoing request body, masks sensitive entities (names, emails, identity numbers, credit cards and more), forwards the clean body to the provider, and restores the original values in the response before it returns to the client. Nothing is written to disk; the restoration mapping is held in memory only and is deleted the moment the response has been sent (see the Attestation header below).
2. Authentication
Authorization: Bearer zpii_<key>
A key is issued from the console (Settings -> API Keys) per organization; an operator of a self-hosted deployment configures keys
in the gateway configuration. An error response for a wrong/missing key: 401 with the code INVALID_API_KEY.
3. Custom Headers
3.1 Request Headers (Client -> Gateway)
| Header | Description |
|---|---|
X-zer0pii-Upstream-Key |
The provider's real API key (BYOK) - forwarded directly to the provider and not stored on the server. |
X-zer0pii-Upstream-URL |
Override of the provider's base URL (for example an internal endpoint). Resolved through an SSRF-hardened resolver (DNS pinning), and does not follow redirects. |
X-zer0pii-Policy-Group |
Manual policy assignment (for example finance, hr, healthcare, clinical) - determines whether the fail-closed group applies and which date fields are masked. |
X-zer0pii-Conversation-ID |
A stable conversation identifier for consistent tagging across turns (preserves Prompt Caching). When it is absent, the scope is organizational. |
3.2 Response Headers (Gateway -> Client)
| Header | Example | Meaning |
|---|---|---|
X-zer0pii-Mode |
standard / partial / degraded-deterministic |
standard: the request also passed the semantic layer. partial: the semantic layer ran but skipped at least one field (the field count is in X-zer0pii-Semantic-Skipped). degraded-deterministic: the request passed deterministic masking only. |
X-zer0pii-Semantic-Skipped |
1 |
Present only when the semantic layer skipped at least one field: the number of fields that were not scanned. |
X-zer0pii-Latency |
total=<ms>; scan=<ms>; vault=<ms> |
A breakdown of the time the gateway added to the request (excluding the provider's response time). Returned on every response, so you can measure it on your own traffic. |
X-zer0pii-Redacted-Count |
3 |
The number of entities masked in the request. |
X-zer0pii-Request-ID |
req_... |
A unique identifier for tracing against the audit log in the console. |
X-zer0pii-Attestation |
t=1772985600;sig=ed25519:...;status=purged |
A signed receipt confirming that the raw request was not retained beyond the processing time. Independent verification against GET /.well-known/jwks.json. |
X-zer0pii-Risk |
min=0.82; low=1 |
Optional, only when a calibration model is loaded - an advisory risk signal, not a misleading default value. |
X-zer0pii-Injection-Signatures |
2 |
Optional - the number of prompt-injection signatures matched in a request that was flagged but still forwarded. |
4. Endpoints
4.1 POST /v1/chat/completions (OpenAI)
Compatible with the OpenAI Chat Completion schema, including support for stream: true (Server-Sent Events).
curl https://api.zer0pii.com/v1/chat/completions \
-H "Authorization: Bearer zpii_your_key" \
-H "X-zer0pii-Upstream-Key: your_openai_key" \
-H "Content-Type: application/json" \
-d '{
"model": "gpt-4o",
"messages": [
{"role": "user", "content": "Summarize the loan file for John Doe, ID 012345672."}
]
}'
4.2 POST /v1/messages (Anthropic)
Compatible with the Anthropic Messages API schema.
curl https://api.zer0pii.com/v1/messages \
-H "Authorization: Bearer zpii_your_key" \
-H "X-zer0pii-Upstream-Key: your_anthropic_key" \
-H "Content-Type: application/json" \
-d '{
"model": "claude-sonnet-4-5",
"max_tokens": 1024,
"messages": [
{"role": "user", "content": "Summarize the loan file for John Doe, ID 012345672."}
]
}'
4.3 POST /v1/models/{model}:generateContent (Gemini)
Compatible with the Google Gemini generateContent schema (and streamGenerateContent for streaming).
curl "https://api.zer0pii.com/v1/models/gemini-2.0-flash:generateContent" \
-H "Authorization: Bearer zpii_your_key" \
-H "X-zer0pii-Upstream-Key: your_gemini_key" \
-H "Content-Type: application/json" \
-d '{
"contents": [
{"role": "user", "parts": [{"text": "Summarize the loan file for John Doe, ID 012345672."}]}
]
}'
4.4 POST /v1/embeddings
Opt-in only and lossy: it exists only for an organization that enabled the feature flag
embeddings_lossy_optin. Any other organization receives a plain 404, indistinguishable from a path that does not exist. Every
successful response carries "zer0pii_caveat" in the body and the header X-zer0pii-Lossy: true.
4.5 GET /health
A liveness check without authentication. The response body contains only status and attestation_kid (the identifier
of the public key for verifying receipts). Internal diagnostic detail (counters, degradation state, SIEM) has moved to the path
GET /v1/health/detail, which requires the same authentication as /v1/events.
4.6 GET /ready
A readiness check for traffic routing - 200 or 503 with a list of reasons. This is the path a
load balancer should be based on, not /health.
4.7 GET /.well-known/jwks.json
Public keys (Ed25519, JWKS) for independent verification of the Attestation signature, without authentication.
5. Error Structure (Problem Detail)
Every error response is an RFC 7807 Problem Detail:
{
"type": "https://zer0pii.com/errors/invalid-api-key",
"title": "Unauthorized",
"status": 401,
"detail": "...",
"code": "INVALID_API_KEY"
}
The X-zer0pii-Request-ID header is attached to an error response as well, so that the failure can be traced in the audit
log.
Common error codes:
| HTTP | Code | Meaning |
|---|---|---|
400 |
UNSAFE_UPSTREAM |
The X-zer0pii-Upstream-URL address was rejected by the SSRF checker. |
401 |
INVALID_API_KEY |
A missing, invalid or expired key. |
403 |
PROMPT_INJECTION_DETECTED |
Prompt injection was detected in blocking mode (opt-in; the default is flagging only). |
422 |
POLICY_THRESHOLD_BLOCKED |
An organizational policy threshold was crossed. |
422 |
CONTENT_TOO_DEEPLY_NESTED |
The message content is nested deeper than the gateway scans, so the request was not forwarded. Flatten the content structure; retrying the same request will not help. |
502 |
UPSTREAM_PROVIDER_ERROR |
The external provider (OpenAI/Anthropic/Gemini) returned an error. |
503 |
CIRCUIT_BREAKER_ACTIVE |
The request was assigned to a policy group that requires full inspection (for example finance or healthcare, see X-zer0pii-Policy-Group) and the semantic layer is unavailable, so the request was not forwarded. This is not an organization-level switch: blocking by information type is set in the closed policy, see below. |
422 |
DEGRADED_SCAN_BLOCKED |
The organization configured blocking when an inspection does not complete, and at least one inspection did not complete for this request. Under the closed policy the body also includes labels: an array of the names of the information types that were not inspected (names only, no values). Retrying the same text will not help. |
5.1 Blocking When an Inspection Does Not Complete (closed)
The organization's degraded_policy policy accepts the values allow, flag, block and closed.
block blocks every request part of which was not scanned. closed blocks only when an inspection of an information type
from the organization's closed list did not complete for this request. An inspection that completed and found nothing passes.
- The default for the closed list: secrets (keys, tokens, passwords) and regulated identifiers (credit card, IBAN, identity documents, passport, tax numbers). Names, organizations and locations remain open unless the organization chose otherwise.
- The organization reads and updates the list in the console, or with
GET/PUT/DELETEon/v1/closed-labels. Removing a secret type from the list requires explicit confirmation (confirm_secret_removal). - Detection of names (person, place, organization) is a best-effort effort: it skips very large fields or fields that are not text, so name labels in the closed list operate on a best-effort basis.
- An information type the organization chose not to mask is not blocked: the effective list is the closed list minus the types that were allowed.
- The decision is made before any call to the provider, including streaming requests, so a stream is not cut mid-way.
- The
GET /v1/site-policypath (for the browser extension) also returnsclosed_labels, and the extension blocks submission when a type from the list is not covered by local masking and the server is unavailable. Binary request bodies are not blocked and receive a warning message only.
5.2 Showing the Real Values in Responses, per Site (restore)
In a site configuration (POST /v1/site-policies) you can send the field restore (boolean, default true).
false means the extension leaves the response on this site as the model wrote it. The field changes only what is displayed on screen:
what is sent to the AI site is masked in any case.
restorecan be sent withoutenforcement_mode. A new site then receives a row with no mode override (enforcement_modeisnull) and the organization's mode keeps applying. On an existing site the mode is preserved.- Sending
enforcement_modeonly leavesrestoreas it is. A value that is not boolean returns400with the codeINVALID_RESTORE. GET /v1/site-policyreturnsrestorefor the site, andGET /v1/site-policiesreturns it on every row.
6. Machine-Readable Schema (OpenAPI JSON)
The full schema is generated directly from the application at build time, filtered to client-facing paths only,
and is served at /openapi.json on the site.