Skip to main content

Overview

Portkey’s Bring Your Own Guardrails (BYOG) webhook allows Fiddler to evaluate prompts and responses flowing through Portkey and either allow, block, or redact PII and secrets — all without Fiddler sitting in the traffic path. Unlike Kong Guardrails (which can only block), Portkey supports transformedData — the adapter can return modified request or response JSON with PII/secrets redacted inline. This is closer to LiteLLM Guardrails behavior.
Portkey’s BYOG webhook feature is available on all Portkey tiers (cloud and self-hosted) — unlike OTel trace export which is enterprise/self-hosted only (see Portkey Integration). The Fiddler guardrail adapter requires a Fiddler deployment with guardrails enabled. On self-hosted Portkey gateways, the Fiddler webhook URL must be allowlisted in TRUSTED_CUSTOM_HOSTS if it is on a private network.

Architecture

Prerequisites

  • A running Fiddler deployment with guardrails enabled
  • A Fiddler API key with guardrails read permission
  • A running Portkey instance (cloud or self-hosted)

Setup

1

Create a BYOG Guardrail in Portkey

In your Portkey configuration, create a guardrail with the BYOG webhook type:
The FIDDLER_API_KEY is a secret — do not commit it to source control. Inject it from your secret manager.
2

Attach the Guardrail to Your Portkey Config

Attach the guardrail check to your Portkey virtual key or config. You can choose to scan:
  • beforeRequestHook — scans the user’s prompt before it reaches the LLM
  • afterRequestHook — scans the LLM’s response before it reaches the user
  • Both — scans both prompts and responses
Refer to Portkey’s guardrail documentation for configuration details.
3

Verify the Integration

Send a test request through Portkey with PII content to verify the guardrail is working:
If guardrails are working, the SSN will be replaced with [REDACTED SOCIAL_SECURITY_NUMBER] in the request that reaches the LLM.

Wire Contract

Request (Portkey → Fiddler)

Portkey POSTs the following JSON to /v3/guardrails/portkey:

Response (Fiddler → Portkey)

Decision Mapping

Redaction Example

When PII is detected in a beforeRequestHook, the response includes modified request JSON:
For afterRequestHook, the transformedData contains modified response JSON with both the json body and text field redacted.

Which Checks Run

The Portkey guardrail adapter runs three checks: Safety (prompt safety / jailbreak detection), PII, and secrets. Faithfulness — offered elsewhere in Fiddler Protect — is not available on the gateway path.

Data Handling

The guardrail adapter is stateless. Fiddler evaluates the text in-request and returns a decision; no prompt, response, or detection result is retained after the webhook call completes. The only durable artifacts are content-free operational counters (request count, latency). No customer data is stored, logged, or used for model training.

Troubleshooting

Webhook returns 503 or times out on first request The guardrails ML models may need to warm up on first request. Set the Portkey webhook timeout to at least 30 seconds (30000ms) for the initial call. Subsequent calls are typically under 2 seconds. Webhook returns 400 The request payload is invalid. Ensure eventType is either "beforeRequestHook" or "afterRequestHook". Check that the payload is valid JSON. Webhook returns 403 The Fiddler API key does not have guardrails permission, or guardrails are not enabled on the Fiddler deployment. PII not being redacted (verdict true, no transformedData) The PII detection model may not have detected PII in the text. The adapter only returns transformedData when PII or secrets are detected above the configured confidence threshold (default: 0.5 for PII in production deployments). Also verify the request.text or response.text field contains the content to scan — Portkey extracts these from the message body.

Next Steps