List of Guardrail Checks

Each Guardrail Check has a specific purpose, it's own parameters, supported hooks, and sources.

Partner Guardrails

Portkey has partnered with leading AI Guardrails companies Patronus AI, Aporia, and Pillar to bring their Guardrails frameworks on to the Portkey Gateway and make them available for Portkey's worldwide users.

Bring Your Own Guardrail

We have built Guardrails in a very modular way, and support bringing your own Guardrail using a custom webhook! Learn more here.


The logic for all of the Guardrail Checks (including Partner Guardrails) is open source.

View it here and here on the Portkey Gateway repo.

Portkey's Default Guardrail Checks

Along with the partner Guardrails, there are also deterministic as well as LLM-based Guardrails supported natively by Portkey.

Check out their details below:

Check NameDescriptionParametersSupported Hooks

Regex Match

Check if the request or response text matches a regex pattern.

rule: string

beforeRequestHook afterRequestHook

Sentence Count

Checks if the content contains a certain number of sentences. Ranges allowed.

minSentences: number maxSentences: number

beforeRequestHook afterRequestHook

Word Count

Checks if the content contains a certain number of words. Ranges allowed.

minWords: number maxWords: number

beforeRequestHook afterRequestHook

Character Count

Checks if the content contains a certain number of characters. Ranges allowed.

minCharacters: number maxCharacters: number

beforeRequestHook afterRequestHook

JSON Schema

Check if the response JSON matches a JSON schema.

schema: json

afterRequestHook

JSON Keys

Check if the response JSON contains any, all or none of the mentioned keys.

keys: array operator: string

afterRequestHook

Contains

Checks if the content contains any, all or none of the words or phrases.

words: array operator: string

afterRequestHook

Valid URLs

Checks if all the URLs mentioned in the content are valid

onlyDNS: boolean

afterRequestHook

Contains Code

Checks if the content contains code of format SQL, Python, TypeScript, etc.

format: string

afterRequestHook

Webhook

Makes a webhook request for custom guardrails

webhookURL:string headers: json

beforeRequestHook afterRequestHook

Moderate Content (LLM-based)

Checks if the content passes the mentioned content moderation checks.

categories: array

beforeRequestHook

Check Language (LLM-based)

Checks if the response content is in the mentioned language.

language: string

beforeRequestHook

Detect PII (LLM-based)

Detects Personally Identifiable Information (PII) in the content.

categories: array

beforeRequestHook afterRequestHook

Detect Gibberish (LLM-based)

Detects if the content is gibberish.

boolean

beforeRequestHook afterRequestHook


Contribute Your Guardrail

We actively welcome Guardrail platforms to integrate their APIs with Portkey Gateway and let Portkey Gateway users use your Guardrail with Portkey's fast & reliable AI Gateway.

Check out some existing examples here to create your own!

Last updated