Skip to content

integration: Add PromptGuard AI security guardrails plugin#1595

Open
acebot712 wants to merge 1 commit intoPortkey-AI:mainfrom
acebot712:integration/promptguard-plugin
Open

integration: Add PromptGuard AI security guardrails plugin#1595
acebot712 wants to merge 1 commit intoPortkey-AI:mainfrom
acebot712:integration/promptguard-plugin

Conversation

@acebot712
Copy link
Copy Markdown

Summary

Adds PromptGuard as a guardrails plugin for the Portkey AI Gateway. PromptGuard is an ML-powered AI security firewall that provides real-time threat detection and PII protection for LLM traffic.

Plugin functions

Function Hook Description
Security Scan beforeRequestHook, afterRequestHook ML-powered detection of prompt injection, jailbreaks, and toxicity
PII Redaction beforeRequestHook, afterRequestHook Detect and optionally redact PII (emails, phones, SSNs, credit cards, etc.)

Files added/changed

  • plugins/promptguard/manifest.json — Plugin manifest with credentials and function definitions
  • plugins/promptguard/scan.ts — Security scan handler (prompt injection, jailbreak, toxicity detection)
  • plugins/promptguard/redact.ts — PII detection and redaction handler with content transformation
  • plugins/promptguard/promptguard.test.ts — 7 unit tests covering credential validation, empty input, and edge cases
  • conf.example.json — Added promptguard to plugins_enabled

Credentials

Field Required Description
apiKey Yes PromptGuard API key (encrypted). Get one at https://app.promptguard.co
baseUrl No Custom base URL for self-hosted deployments. Defaults to https://api.promptguard.co/api/v1

Configuration example

{
  "name": "promptguard-scan",
  "provider": "promptguard",
  "credentials": {
    "apiKey": "pg_live_..."
  },
  "function": "scan",
  "onSuccess": "allow",
  "onFail": "deny"
}

Test plan

  • All 7 unit tests pass (npx jest plugins/promptguard/ --no-coverage)
  • prettier --check passes (pre-commit hook verified)
  • eslint passes with zero errors
  • Build succeeds (rollup -c via pre-push hook)
  • Gateway starts successfully (verified via pre-push hook)

Add PromptGuard as a guardrails plugin for the Portkey AI Gateway.
PromptGuard provides ML-powered security scanning and PII redaction
for LLM inputs and outputs.

Plugin functions:
- scan: Detect prompt injection, jailbreaks, and toxicity
- redact: Detect and redact PII (emails, phones, SSNs, etc.)

Both functions support beforeRequestHook and afterRequestHook.

Includes:
- manifest.json with plugin configuration
- scan.ts handler for security scanning
- redact.ts handler for PII redaction
- promptguard.test.ts with 7 unit tests (all passing)
- Registration in conf.example.json
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant