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

Partner Guardrails

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 MatchCheck if the request or response text matches a regex pattern.rule: stringbeforeRequestHook afterRequestHook
Sentence CountChecks if the content contains a certain number of sentences. Ranges allowed.minSentences: number maxSentences: numberbeforeRequestHook afterRequestHook
Word CountChecks if the content contains a certain number of words. Ranges allowed.minWords: number maxWords: numberbeforeRequestHook afterRequestHook
Character CountChecks if the content contains a certain number of characters. Ranges allowed.minCharacters: number maxCharacters: numberbeforeRequestHook afterRequestHook
JSON SchemaCheck if the response JSON matches a JSON schema.schema: jsonafterRequestHook
JSON KeysCheck if the response JSON contains any, all or none of the mentioned keys.keys: array operator: stringafterRequestHook
ContainsChecks if the content contains any, all or none of the words or phrases.words: array operator: stringafterRequestHook
Valid URLsChecks if all the URLs mentioned in the content are validonlyDNS: booleanafterRequestHook
Contains CodeChecks if the content contains code of format SQL, Python, TypeScript, etc.format: stringafterRequestHook
WebhookMakes a webhook request for custom guardrailswebhookURL:string headers: jsonbeforeRequestHook afterRequestHook
Moderate Content (LLM-based)Checks if the content passes the mentioned content moderation checks.categories: arraybeforeRequestHook
Check Language (LLM-based)Checks if the response content is in the mentioned language.language: stringbeforeRequestHook
Detect PII (LLM-based)Detects Personally Identifiable Information (PII) in the content.categories: arraybeforeRequestHook afterRequestHook
Detect Gibberish (LLM-based)Detects if the content is gibberish.booleanbeforeRequestHook 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