Skip to main content

Guard API

The Guard API lets you scan arbitrary text for prompt injection, jailbreak attempts, PII leaks, and other threats without forwarding anything to an LLM provider. Use it when you want fine-grained control over when and how security checks run.
This is the same detection engine used by the proxy and auto-instrumentation SDKs. The Guard API simply exposes it as a standalone endpoint.

Endpoint

Authentication

Request Body

GuardMessage

GuardContext (optional)

DeviceFinding (optional)

Sent by the PromptGuard desktop agent, which masks secrets and personal data on the device before it scans. The engine then only sees the masked text, so the agent reports what it caught. You do not need this field unless you are building a client that masks before scanning. A finding is a category and a count, never the value itself. A finding with any other key (for example value), an unknown category, or a count that is not a positive whole number is rejected with 422. Findings appear in the Shadow AI fleet views for the device that sent them. They do not change the decision. A request that carries findings and nothing to scan is a findings-only report, and it does not count as a scan against your plan. That means every message’s content is exactly "" or [], and there is no media, retrieved_context or context.tool_calls. Its findings are still recorded for the device. Anything else counts as a scan, whatever findings come with it. That includes whitespace, a single content block, an attachment, a retrieved document or a tool call. A request with no findings counts as it always has.

Response

ThreatDetail

Unavailable checks

An allow with a non-empty unavailable does not mean every check passed. Each entry is a detector this scan would have run but the deployment cannot, because its backing service is not configured — typically a self-hosted install with no LLM judge. Those detectors never looked at the content; the rest ran as usual.
A detector that ran and found nothing is not listed, and neither is one your plan or guardrail settings turn off, or one this scan’s direction does not run (an output scan runs no prompt-injection detectors). The dashboard shows a reduced-coverage banner listing every Unavailable check in the deployment, whichever project it would apply to. On an air-gapped install the banner names the setting to change; in PromptGuard Cloud, where there is nothing for you to configure, it says the check is currently unavailable. The reason codes below are the same in both.

Attachments

Attachments are extracted to text and run through the same detectors as typed text. An injection in a PDF’s body copy, in its /Subject metadata, in a screenshot, or spoken in an audio clip is an injection. Two ways to send them, and you can mix both in one request: Content blocks, in either provider’s shape — this is what your existing OpenAI or Anthropic code already produces:
Or the flat media array, which additionally accepts audio:
Supported: application/pdf, text/*, application/json, application/xml, images (OCR), audio (transcription).

unscanned — the field that matters

An allow with a non-empty unscanned does not mean the content was clean. It means the text we could read was clean, and the listed attachments were never read. Treat it as a signal, not a footnote:
That example is a scanned or rasterised PDF — four pages of images with no text layer. It is also the obvious way to smuggle an injection past a text extractor, which is why we report it rather than calling it clean.
Through the proxy (/chat/completions, /messages) the same information comes back as response headers, since the body is the provider’s: X-PromptGuard-Unscanned and X-PromptGuard-Unscanned-Reasons.

Limits

redacted_messages is always the text projection — a message sent as content blocks comes back as a string. Attachments are never rewritten: we do not re-encode a PDF with the secret removed, and returning one that looked redacted would be worse than returning none.

Examples

Scan user input before sending to an LLM

Response

Scan output for PII before returning to user

Response

SDK Usage (GuardClient)

The Guard API is also accessible through the SDK’s GuardClient:

When to use Guard API vs Proxy

Error Responses

A guard call is one request under your monthly quota, and the 429s above follow the same rules and carry the same bodies as the proxy and /api/v1/security/scan. See Plans & Limits.
Scans from an enrolled Shadow AI device — the desktop agent or browser extension, using the key issued when it enrolled — count against the same quota but are never refused for it: a data-loss control that stops at a billing threshold would either block the paste or let it leave unscanned. The exemption belongs to the enrolled device’s key, not to a header: a key you created yourself is metered on /api/v1/guard like any other request, whatever X-PG-Surface it sends. The same goes for where a scan appears: only the enrolled device’s key is counted as Shadow AI activity in the dashboard, and a scan from any other key that sends X-PG-Surface: desktop or browser is recorded as a direct guard call.