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)

Response

ThreatDetail

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