> ## 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.

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`.
