> ## Documentation Index
> Fetch the complete documentation index at: https://docs.neuraltrust.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# Kong

> TrustGuard with Kong ai-custom-guardrail and AI Proxy.

Use Kong **`ai-custom-guardrail`** (needs AI Proxy) to send prompts and completions to
evaluate.

## Coverage

| Surface    | Monitor | Block | Redact |
| ---------- | :-----: | :---: | :----: |
| LLM input  |    ✅    |   ✅   |    ❌   |
| LLM output |    ✅    |   ✅   |    ❌   |
| Tool-level |    ➖    |   ➖   |    ➖   |

**Ask** — the plugin maps the verdict onto a boolean, so an `ask` gate is
**allowed** and recorded. Write the rule as **Block** if you need a hard stop.

**Use it when** Kong AI Proxy is already configured on the routes you protect.
**Not when** you do not use AI Proxy — `ai-custom-guardrail` does not work on its
own — or when you need masking in flight.

**Limits.** Output coverage is documented over non-streaming completions;
validate against a streaming completion before relying on it there.
`concatenate_all_content` flattens the message array, so detectors that depend on
role boundaries see a single blob.

Full comparison: [Coverage](/trustguard/integrations/coverage).

1. Create an API key on the collector.
2. Configure AI Proxy (or AI Proxy Advanced) on the route.
3. Add `ai-custom-guardrail` pointing at evaluate. Put Kong `X-Consumer-ID` in
   `consumer_id` and a conversation id in `session_id`.
4. Block when `status == "block"`.

```yaml theme={null}
plugins:
  - name: ai-custom-guardrail
    config:
      guarding_mode: BOTH
      text_source: concatenate_all_content
      params:
        api_key: "<collector-api-key>"
      request:
        url: {TRUSTGUARD_URL}/v1/evaluate
        headers:
          Authorization: Bearer $(conf.params.api_key)
        body:
          protocol: llm
          direction: input
          payload:
            input: "$(content)"
      response:
        block: "$(check_response.block)"
        block_message: "$(check_response.block_message)"
      functions:
        check_response: |
          return function(resp)
            -- Transform body rewrite needs a downstream plugin; this mapping only
            -- supports block / block_message.
            return {
              block = resp.status == "block",
              block_message = "Blocked by TrustGuard"
            }
          end
```

For output inspection, use `direction: output` on the response pass (or
`guarding_mode: BOTH` if your Kong version maps both). Transform that rewrites bodies
needs more than `block` / `block_message`.
