Skip to main content

Overview

The Kong AI Gateway can enforce Fiddler Guardrails on prompts before they reach the model — blocking personally identifiable information (PII) and secrets at the gateway. It uses Kong’s ai-custom-guardrail plugin, which calls Fiddler’s Kong guardrail adapter (/v3/guardrails/kong) on each request. This page covers guardrail enforcement. For LLM tracing setup — the ai-proxy and opentelemetry plugins, session grouping, and span mapping — see the Kong AI Gateway Integration. The two are independent plugins on the same route:
Guardrails require Kong Gateway 3.14 or later with an AI Gateway Enterprise license — ai-custom-guardrail is gated behind Kong’s separately licensed AI Gateway Enterprise offering (its plugin page carries an “AI License Required” badge), which is not the same as a plain Kong Gateway Enterprise subscription. Tracing alone works on Kong 3.13+.

How It Works

Each prompt is checked before the model is called (guarding_mode: INPUT). Prompts with no detections continue to the model; prompts containing PII or secrets are blocked before the model is called (HTTP 400 by default). Post-call output guarding is also supported — see Output Guarding. Fiddler detections on Kong block; they are not masked. Kong’s ai-custom-guardrail plugin does expose an allow_masking option, but its response contract for a custom guardrail service exposes only two fields — block and block_message — so there is no field through which a Fiddler-supplied redaction could be returned. Detections are therefore blocked, not redacted. (allow_masking also disables streaming, per Kong’s schema.) For redaction, see the LiteLLM or AgentGateway integrations.
The Guardrail span you may see in Fiddler is emitted by your own Kong check function and exported by your own opentelemetry plugin — not by Fiddler’s adapter. See Data Handling.

Prerequisites

Before you start, confirm each of the following:
  • Fiddler guardrails are enabled on your deployment. If they are not, the adapter returns HTTP 403 “Guardrails is not enabled for this cluster” or HTTP 404 “not available on freemium deployments” — see Troubleshooting. Contact your Fiddler administrator if you are unsure.
  • Your Fiddler instance URL (for example https://your-instance.fiddler.ai) and a Fiddler API key (found under organizational settings).
  • Kong Gateway 3.14+ with an AI Gateway Enterprise license (see the callout above).
  • untrusted_lua = on on your Kong deployment — required for the inline check function (set it as KONG_UNTRUSTED_LUA=on or in kong.conf; it cannot be set in declarative config).
  • A provider API key for the model Kong proxies (for example OPENAI_API_KEY).
  • Network egress from Kong to your Fiddler instance over HTTPS.
  • About ten minutes.

Quick Start

1

Add the Guardrail Plugin to Your Kong Config

Add ai-custom-guardrail to the same route you proxy through ai-proxy. The minimal declarative config below is self-contained — a service, a route, ai-proxy with the provider key supplied by a Kong Vault reference, and the guardrail plugin with an inline check function that emits a connected Guardrail span:
The ${FIDDLER_URL} and ${FIDDLER_API_KEY} values are placeholders. Kong does not read environment variables from its declarative config, so replace each ${...} with your actual value before starting Kong — otherwise Kong fails to start. Treat the resulting file as a secret: restrict its file permissions and inject it at deploy time from your secret manager rather than committing it.
2

Enable Untrusted Lua

The check function above runs inline Lua, which Kong loads only when untrusted_lua = on. Set KONG_UNTRUSTED_LUA=on (or untrusted_lua = on in kong.conf) at the process level — it cannot be set in declarative config. Without it, Kong refuses to load the check function and the Guardrail span is never emitted.
3

Send a Test Request

Send a prompt through Kong’s OpenAI-compatible endpoint. A prompt containing PII or secrets is blocked at the gateway with HTTP 400; a benign prompt is forwarded to the model:
The expected outcomes follow from the adapter’s wire contract in Check Behavior: a prompt with PII or secrets is rejected with the block reason, and a benign prompt returns an ordinary provider response. Confirm them against your own Kong deployment — Fiddler does not publish a captured transcript for this release. Use synthetic data only — never a real credential or real personal data.

What This Configuration Enables

The quick-start config sends no check-selection parameters, so the adapter runs both of its checks on the request path: One thing about this behavior is important, and it cannot be changed on Kong:
  • Kong’s request contract carries no guardrail configuration. The adapter accepts only input and input_type, and silently ignores any other field — so a parameter copied from another gateway’s setup (for example LiteLLM’s additional_provider_specific_params) has no effect.

Check Behavior

Kong extracts the text — the prompt on the request path, or the buffered model output on the response path — and posts it to the adapter, which runs the checks and returns a block decision. Request
Response — allowed:
Response — blocked. The reason string identifies which check fired:
A blocked response can carry one of a few reason shapes, depending on the detection:
  • PII or secrets: “Sensitive information (PII or secrets) detected — blocking request (cannot be redacted via Kong).”
  • A generic fallback: “Request blocked by guardrail.”
Kong’s check function maps block to whether the request is rejected and reason to the client-facing block_message. The underlying checks are the same PII checks described in Fiddler Guardrails, plus secrets detection. The adapter endpoint path is exactly /v3/guardrails/kong. A case variant (for example /v3/guardrails/Kong) is routed to Fiddler’s generic guardrails API instead, and a trailing slash (/v3/guardrails/kong/) returns HTTP 404 — so keep the path lowercase and unslashed.

Output Guarding

The Quick Start config guards the input prompt (guarding_mode: INPUT, sending input_type: "request"). To guard the model output, add a second ai-custom-guardrail plugin in guarding_mode: OUTPUT whose request body sets input_type: "response" — in output mode Kong’s $(content) resolves to the model’s response:
Here $(resp.block) and $(resp.reason) map directly to the adapter’s response fields, so a blocked output is rejected (HTTP 400 by default) with the block reason. On the response path the adapter runs the same PII and secrets checks. As with the input config, replace the ${FIDDLER_URL} and ${FIDDLER_API_KEY} placeholders with your actual values, and add a functions.check block like the one in the Quick Start if you want a connected Guardrail span on the output path too. Output redaction is not available on Kong — output detections block, they are not redacted.

Failure Behavior

The Kong guardrail adapter is fail-open on the Fiddler side and offers no control to change it:
  • On a detector timeout or an inference error, the adapter returns block: false and the unscanned content reaches the model. There is no customer-side lever to make it fail closed.
  • The adapter’s wall-clock budget is a fixed 12 seconds and is not adjustable from Kong.
  • An unexpected error inside the adapter surfaces as HTTP 500 to Kong. What Kong does then is governed by the plugin’s own stop_on_error field, which defaults to true — so by default Kong stops processing the request on an adapter error rather than letting it through. Kong’s plugin also has its own connection timeout (default 10,000 ms), separate from Fiddler’s 12-second budget.
If your policy requires traffic to be blocked when guardrails are unavailable, stop_on_error: true (Kong’s default) is the nearest available control — verify it in your environment, because it governs Kong’s behavior, not Fiddler’s.

Data Handling

Fiddler’s Kong guardrail adapter is stateless:
  • Fiddler evaluates the text in-request and returns a decision. No prompt, no response, and no detection result is written to any Fiddler datastore, and Fiddler emits no span.
  • The only durable record is two content-free operational counters (Prometheus series) labelled by gateway, direction, and outcome. There is no per-request guardrail decision log or dashboard for this integration.
  • The Guardrail span you see in Fiddler is emitted by your own Kong check function and exported by your own opentelemetry plugin. Without KONG_UNTRUSTED_LUA=on and that check block, a guardrail call leaves no trace in Fiddler at all.
Prompt text retention. If you extend the check function to copy the user prompt onto the Guardrail span — for example span:set_attribute("gen_ai.llm.input.user", prompt) — that prompt text is ingested and stored with the span like any other trace content. This is the one place in this integration where prompt text enters Fiddler storage. Kong itself warns that gen_ai.input.messages and gen_ai.output.messages may contain PII, secrets, or credentials. Omit that line if you do not want prompt text retained.

Troubleshooting

HTTP 403 or 404 from the guardrail adapter A 403 (“Guardrails is not enabled for this cluster”) or 404 (“not available on freemium deployments”) means Fiddler guardrails are not enabled on your deployment — not a Kong configuration problem. Contact your Fiddler administrator to confirm your deployment’s entitlement. Guardrail not blocking / no Guardrail span appearing ai-custom-guardrail requires Kong 3.14+ with an AI Gateway Enterprise license — it is silently absent without that license. Confirm the license, that KONG_UNTRUSTED_LUA=on is set (required for the check function that emits the span), and that the ${FIDDLER_URL}/v3/guardrails/kong URL and Authorization header in the plugin config are correct. Check your Kong logs for errors calling the adapter. Prompt missing from the LLM span when guardrails are enabled Fiddler has observed, on Kong 3.14.0.x with an AI Gateway Enterprise license, that when an ai-custom-guardrail plugin shares the route, Kong drops gen_ai.input.messages from the LLM span and degrades gen_ai.output.messages to the raw response-body map. This is a Fiddler observation, not a Kong-acknowledged bug: it does not appear in Kong’s changelog or issue tracker as of 2026-08-19. Kong’s Gen AI OpenTelemetry tracing is itself labelled Tech Preview — “currently in Tech Preview and should not be used in a production environment” — so re-verify this behavior in your own environment and after Kong upgrades. As a workaround, stamp the prompt onto the Guardrail span from the check function (see the retention warning in Data Handling before doing so). The optional check function below does this — it reads the last user message from the request body and writes it to the span as gen_ai.llm.input.user. It is opt-in because it stores that prompt text in Fiddler: review the retention warning above first, and omit the prompt line if you do not want retention.

Known Limitations

Next Steps