Skip to main content
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.
Shortest path to a first block, about 5 minutes: sign up → create a key → run one command (the Guard API curl below, which needs no SDK and no LLM provider key). To protect an existing app, follow the three steps below: key, install, then one script that shows an allowed and a blocked request.

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-python and engines in the published packages). The Guard API and proxy work from any language that speaks HTTPS.
  • An OpenAI API key in OPENAI_API_KEY for 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.co from wherever the code runs.
Install commands on this page install the latest release of each package, so they never point at an old version; pin the version you tested in your own lockfile (requirements.txt, package-lock.json).
1

Get your API key

  1. Sign in at app.promptguard.co (sign-up creates a Default Project for you)
  2. Open your project and go to API Keys
  3. Click Create key, name it, and copy the key
Store the key securely. It is only shown once.
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.
2

Install the SDK

3

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.
Node.js: the sample is CommonJS on purpose. Auto-instrumentation patches the provider SDK that Node loads through require(). In a native ES module app ("type": "module" or .mjs), import OpenAI from 'openai' loads OpenAI’s separate ESM build, which is not patched: the call goes straight to OpenAI, and getAppliedPatches() still lists openai. In an ESM app, load the provider SDK with createRequire so it is the patched copy:
Or call the Guard API explicitly. TypeScript compiled to CommonJS (the tsc default) is not affected. Either way, the script above is the check: protection is live when it prints Blocked:.
4

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.
Pass your LLM provider key in the Authorization header. PromptGuard forwards the request after scanning.

Alternative: Guard API (standalone scan)

Scan content directly without proxying:
Expected output (abridged; from a run on 2026-10-31, with event_id and latency_ms different on every call):
A harmless message such as "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
Last modified on October 31, 2026