What you’re protecting against: PromptGuard blocks prompt injection, jailbreaks, and data leaks before they reach (or leave) your LLM — without changing how your app works. New to these terms? See the glossary.
Before you begin
- A PromptGuard account with a verified email. Sign up at app.promptguard.co. If you sign up with email and password, click the link in the verification email first: creating an API key is refused until the address is verified. Continue with Google and Continue with GitHub accounts are verified already.
- Python 3.10 or later, or Node.js 20 or later for the SDK (
requires-pythonandenginesin the published packages). The Guard API and proxy work from any language that speaks HTTPS. - An OpenAI API key in
OPENAI_API_KEYfor the SDK steps. Your app keeps calling OpenAI with its own key; PromptGuard only scans. Not needed for the Guard API. - Outbound HTTPS to
api.promptguard.cofrom wherever the code runs.
requirements.txt, package-lock.json).
Get your API key
- Sign in at app.promptguard.co (sign-up creates a Default Project for you)
- Open your project and go to API Keys
- Click Create key, name it, and copy the key
PromptGuard API keys always start with the
pg_live_ prefix. Authenticate by passing the key in the X-API-Key header (the SDKs do this for you). There is no separate test or sandbox key prefix.Add one line, then try an attack
Save this as one file and run it. The first call is a normal request; the second is a prompt injection, which PromptGuard should block before it reaches OpenAI.Expected output. From a run on 2026-10-31 (Python SDK 2.4.2 and Node.js SDK 2.4.1 print the same lines); the model’s reply and the event ID differ on every run:The threat type for this prompt is
data_exfiltration (it asks for the system prompt); other injections report prompt_injection. If the second line starts with Allowed: instead, the call was not scanned: check PROMPTGUARD_API_KEY and, in Node.js, the module format below.Auto-instrumentation patches OpenAI, Anthropic, Google AI, Cohere, and AWS Bedrock SDKs. All LLM calls are scanned automatically.
Only a block decision raises
PromptGuardBlockedError. A redact decision does not raise — PromptGuard strips the sensitive content and returns a sanitized response, so the call succeeds normally. The examples use gpt-5-nano; replace it with any model your provider account has access to.See it in the dashboard
Open your project at app.promptguard.co and go to Interactions. Both requests are listed, newest first: the injection with Decision
block, Threats data_exfiltration and its Confidence, and the Hello! request with Decision allow. Click a row for the full event, or open one directly at https://app.promptguard.co/dashboard/events/<event-id> with the event ID the script printed.Alternative: HTTP proxy (no SDK)
Change your LLM base URL to PromptGuard. No SDK installation needed.Authorization header. PromptGuard forwards the request after scanning.
Alternative: Guard API (standalone scan)
Scan content directly without proxying:event_id and latency_ms different on every call):
"What is the capital of France?" returns "decision": "allow" with "threat_type": null and an empty threats list. Both calls appear on your project’s Interactions page, as in the last step above.
See the Guard API reference for the full request/response schema.
What happens under the hood
Next steps
Before production
The checklist before real traffic: keys per environment, fail mode, rate limits, alerting
Security Policies
Configure what is blocked, redacted or flagged for your use case
Python SDK
Full Python SDK reference with configuration options
Node.js SDK
Full Node.js SDK reference, including ES module apps