This document covers third-party plugin integrations in the Portkey AI Gateway. These plugins integrate external AI safety, security, and validation services from specialized vendors. Unlike the built-in default plugins covered in Built-in Plugins and Guardrails, external plugins call external APIs for advanced capabilities like PII detection, content moderation, prompt injection detection, and policy enforcement.
For information on the plugin system architecture, see Plugin System and Registry. For creating your own plugins, see Creating Custom Plugins.
The gateway organizes external plugins into vendor-specific categories within the plugins object exported from plugins/index.ts70-179 Each category represents a third-party service provider and contains one or more plugin functions implementing the PluginHandler interface.
Plugin Registry Architecture
Each handler is imported from its category-specific directory and exported through a nested object structure. For example, plugins.qualifire.pii references the handler imported at plugins/index.ts22 and exported at plugins/index.ts101
Sources: plugins/index.ts1-179
The following table summarizes all external plugin categories available in the gateway. Each category maps to a nested object within the plugins export.
| Category | Plugins | Focus Area | Key Capabilities | Code Location |
|---|---|---|---|---|
qualifire | 7 | AI Safety & Quality | Content moderation, grounding, hallucination detection, PII, prompt injections | plugins/index.ts95-103 |
portkey | 4 | Content Safety | Content moderation, language detection, PII, gibberish detection | plugins/index.ts104-109 |
patronus | 11 | Response Quality | PHI/PII detection, conciseness, helpfulness, bias detection, toxicity | plugins/index.ts120-132 |
azure | 4 | Microsoft Azure AI | PII detection, content safety, prompt shield, protected material detection | plugins/index.ts157-162 |
mistral | 1 | Mistral AI | Content moderation using Mistral's guardrail service | plugins/index.ts133-135 |
bedrock | 1 | AWS Bedrock | Guardrails using AWS Bedrock Guardrails API | plugins/index.ts145-147 |
pangea | 2 | Security | Text guard, PII redaction | plugins/index.ts136-139 |
promptfoo | 3 | Security Testing | PII detection, harm detection, general guard | plugins/index.ts140-144 |
promptsecurity | 2 | Prompt Security | Prompt protection, response protection | plugins/index.ts163-166 |
pillar | 2 | Security Scanning | Prompt scanning, response scanning | plugins/index.ts116-119 |
sydelabs | 1 | AI Safety | Sydeguard guardrails | plugins/index.ts113-115 |
aporia | 1 | ML Monitoring | Project validation | plugins/index.ts110-112 |
acuvity | 1 | Security | Content scanning | plugins/index.ts148-150 |
lasso | 1 | Classification | Content classification | plugins/index.ts151-153 |
exa | 1 | Search | Online search integration | plugins/index.ts154-156 |
walledai | 1 | AI Safety | Walled AI protection | plugins/index.ts170-172 |
javelin | 1 | AI Gateway | Javelin guardrails integration | plugins/index.ts173-175 |
panw-prisma-airs | 1 | Network Security | Palo Alto Prisma AIRS intercept | plugins/index.ts167-169 |
f5-guardrails | 1 | Application Security | F5 guardrails scanning | plugins/index.ts176-178 |
Sources: plugins/index.ts70-179
External plugins are referenced using a two-part identifier: category.pluginName. The hooks system uses this ID to look up and execute the appropriate plugin handler from the plugins object.
Plugin Resolution Flow
All plugin handlers must implement the PluginHandler type signature:
Example hook configuration:
The hooks execution system (see Hook Execution Lifecycle) parses the id field, looks up the handler in the plugins object, and invokes it with the request/response context and configured parameters.
Sources: plugins/index.ts95-103 plugins/default/modelWhitelist.ts1-11
Qualifire provides comprehensive AI safety and quality validation services. These plugins call the Qualifire API to assess various aspects of AI-generated content.
Qualifire Plugin Architecture
Available plugins:
qualifire.contentModeration - Detects harmful, toxic, or inappropriate contentqualifire.grounding - Validates factual grounding of responses against source materialqualifire.policy - Enforces custom organizational policiesqualifire.toolUseQuality - Assesses quality of tool/function callingqualifire.hallucinations - Detects hallucinated or fabricated informationqualifire.pii - Identifies personally identifiable informationqualifire.promptInjections - Detects prompt injection attacksEach handler is imported from plugins/qualifire/ directory and registered in the plugins.qualifire object at plugins/index.ts95-103
Sources: plugins/index.ts17-23 plugins/index.ts95-103
Portkey's built-in AI safety plugins provide content validation by calling Portkey's external services. These plugins integrate with Portkey's hosted AI safety APIs.
Portkey Plugin Architecture
Available plugins:
portkey.moderateContent - Content moderation via Portkey APIportkey.language - Language detection and validationportkey.pii - PII detection serviceportkey.gibberish - Nonsensical or gibberish text detectionEach handler is imported from plugins/portkey/ directory and registered at plugins/index.ts104-109
Sources: plugins/index.ts26-29 plugins/index.ts104-109
Patronus provides the most extensive set of response quality evaluation plugins. These assess various qualitative aspects of AI responses through the Patronus AI API.
Patronus Plugin Architecture
Available plugins:
patronus.phi - Detects protected health informationpatronus.pii - Detects personally identifiable informationpatronus.isConcise - Evaluates response concisenesspatronus.isHelpful - Assesses response helpfulnesspatronus.isPolite - Checks politeness and tonepatronus.noApologies - Detects excessive apologizingpatronus.noGenderBias - Checks for gender biaspatronus.noRacialBias - Checks for racial biaspatronus.retrievalAnswerRelevance - Validates RAG answer relevancepatronus.toxicity - Detects toxic languagepatronus.custom - Custom evaluations via Patronus APIEach handler is imported from plugins/patronus/ directory and registered at plugins/index.ts120-132
Sources: plugins/index.ts34-45 plugins/index.ts120-132
Azure plugins integrate Microsoft Azure AI Content Safety and other Azure cognitive services.
Available plugins:
azure.pii - PII detection using Azure Text Analyticsazure.contentSafety - Content safety assessment using Azure Content Safetyazure.shieldPrompt - Prompt shield protection against jailbreak attemptsazure.protectedMaterial - Detects protected/copyrighted materialSources: plugins/index.ts55-56 plugins/index.ts157-162
Bedrock plugins integrate AWS Bedrock Guardrails for policy-based content filtering.
Available plugins:
bedrock.guard - AWS Bedrock Guardrails integration for policy enforcementSources: plugins/index.ts51 plugins/index.ts145-147
Several categories provide specialized security capabilities:
Promptfoo plugins:
promptfoo.pii - PII detection for security testingpromptfoo.harm - Harmful content detectionpromptfoo.guard - General-purpose guardrailPromptSecurity plugins:
promptsecurity.protectPrompt - Protects prompts from injection attackspromptsecurity.protectResponse - Protects responses from data leakagePillar Security plugins:
pillar.scanPrompt - Scans prompts for security issuespillar.scanResponse - Scans responses for security issuesPangea plugins:
pangea.textGuard - Text content protectionpangea.pii - PII redaction serviceSources: plugins/index.ts46-50 plugins/index.ts55-68 plugins/index.ts136-178
All external plugins implement the PluginHandler interface and follow a common pattern for calling external APIs and returning results.
External Plugin Handler Execution Flow
Handler Structure Pattern
All external plugin handlers follow this template structure:
Common parameter patterns:
API Credentials - Most plugins require API keys or tokens:
Thresholds - Many plugins support configurable thresholds:
Configuration - Plugin-specific configuration:
Sources: plugins/index.ts1-179 plugins/default/modelWhitelist.ts1-58 plugins/default/alluppercase.ts1-66
External plugins are configured in hook definitions using the id field with category prefix:
The hooks system resolves these IDs by:
. to get category and function nameplugins[category][functionName]Sources: plugins/index.ts70-179
To add a new external plugin category:
plugins/{category}/plugins/index.tsplugins export object:PluginHandler interface{error, verdict, data} structureFor detailed implementation guidance, see Creating Custom Plugins.
Sources: plugins/index.ts1-179
Sources: plugins/index.ts70-179
External plugins require API credentials. These can be provided via:
Direct parameters - In hook configuration:
Environment variables - Using variable syntax:
File-based secrets - For sensitive credentials:
The gateway resolves environment variables and file contents before passing parameters to plugin handlers.
Sources: plugins/index.ts1-179
Refresh this wiki