Related Documentation
Made by
Compatible Protocols
grpc grpcs http https
Minimum Version
Kong Gateway - 3.14
Tags

Third Party: This plugin is developed, tested, and maintained by Straiker.

Use the Straiker plugin (straiker) to protect LLM traffic flowing through Kong Gateway. The plugin scans prompts before they reach the upstream model and scans model responses before they return to the client.

This plugin can protect chat applications and coding agents. It speaks Anthropic Messages and OpenAI chat, so it also protects agents such as Claude Code.

Straiker evaluates each turn against the policies configured in the Straiker Console, and Kong Gateway forwards the traffic or replaces it with a policy message based on the verdict.

Note: This plugin is built for AI Gateway running on Kong Gateway. It has not been validated against AI Gateway 2.0.

With Straiker, you can:

  • Block unsafe traffic at the gateway: Detect prompt injection, jailbreaks, sensitive data exposure, and unsafe model output.
  • Inspect indirect prompt injection: Catch poisoned tool results arriving from a coding agent’s local tool run.
  • Stop a tool call before it runs: Prevent a model’s tool call from reaching the agent, on routes configured for it.
  • Centralize AI security enforcement: Apply one policy across applications, models, and providers.
  • Hold the upstream credential at the gateway: Clients never carry a platform key.
  • Inspect streaming and multimodal traffic: Evaluate AI traffic without adding an application SDK.

Delivery mode

The Straiker plugin enforces in one of two modes, selected by the STRAIKER_KONG_MODE environment variable on the Kong Gateway node. Set it to buffered (the default) or streaming.

Capability

buffered (default)

streaming

Prompt and tool-result enforcement Yes Yes
Stops a tool call before the client runs it Yes No
Tokens reach the client as produced No Yes
Time to first token The completion time Unchanged
Typical route CI, automation, unattended agents Interactive developers

The mode applies to the whole node, so run two node pools if you need both modes.

The mode setting is an environment variable because Kong Gateway rejects a plugin that implements both the response and body_filter phases, and checks this at load time, before reading any configuration.

The Straiker plugin doesn’t require AI Proxy. It proxies provider traffic directly and injects the upstream credential itself.

Caution: If you use AI Proxy, keep it off nodes running STRAIKER_KONG_MODE=buffered. AI Proxy turns response buffering off whenever the client streams, which means the plugin’s response phase never runs and enforcement stops silently. Use streaming mode on those routes instead.

How it works

Before the request reaches the model:

  1. Credential injection: The plugin replaces the client’s upstream credential with the one the gateway holds.
  2. Request interception: The plugin captures the incoming request body.
  3. Security scan: The plugin sends the turn to Straiker for policy evaluation.
  4. Verdict enforcement: Kong Gateway blocks the request or forwards it to the upstream model.

After the model responds:

  1. Response capture: The plugin captures the model’s answer. It holds the answer inline in buffered mode and passes it through as the model produces it in streaming mode.
  2. Response scan: The plugin sends the answer to Straiker for evaluation.
  3. Final delivery: In buffered mode, Kong Gateway replaces the answer if the verdict is a block. In streaming mode, the client already has the bytes and the verdict is advisory.
sequenceDiagram
    autonumber
    participant client as Client
    participant straiker as Kong Gateway<br/>Straiker plugin
    participant detect as Straiker
    participant llm as Upstream AI service

    client->>straiker: Send request
    straiker->>detect: Send turn
    detect->>detect: Check against AI security policy
    detect-->>straiker: Verdict

    alt Prompt blocked
        straiker-->>client: Return policy message
    else Prompt allowed
        straiker->>llm: Forward allowed request
        llm-->>straiker: Return AI response
        straiker->>detect: Send answer
        detect-->>straiker: Verdict

        alt Answer blocked (buffered mode)
            straiker-->>client: Return policy message
        else Answer allowed
            straiker-->>client: Forward allowed response
        end
    end

A block is returned as HTTP 200 carrying a completed assistant turn whose content is the policy text. It’s deliberately not a 4xx or 5xx response, because coding agent clients treat 403 as an authentication failure and retry 5xx. Set up alerts on the x-straiker-verdict response header instead of the HTTP status.

Install the Straiker plugin

The plugin is supported on self-managed Kong Gateway, Konnect hybrid deployments with self-managed data planes, and Konnect Dedicated Cloud Gateways.

Konnect Serverless Gateways don’t support custom plugins.

Prerequisites

Before installing the plugin, you need:

  • Kong Gateway 3.14 or later.
  • A Straiker account and integration key.
  • Network egress from Kong Gateway data planes to the Straiker detect endpoint.
  • nginx_http_client_body_buffer_size raised to 32m. At the nginx default of 8 KB, a large request body spills to a temporary file, the plugin can’t read it, and traffic proxies uninspected.
  • max_body_bytes raised to match. The plugin skips scoring for a body larger than this limit, which defaults to 10 MiB.

Installation steps

Enable the plugin

Attach straiker to the Route carrying LLM traffic. The plugin scores any POST request on that Route and doesn’t inspect the path, so scope the Route deliberately. A plain Kong Gateway path is a prefix match.

Declare protocols explicitly on the Route. Without it, Kong Gateway infers them from the Service URL, an https:// upstream makes the Route HTTPS-only, and plain HTTP is rejected with 426 Upgrade Required before any plugin runs.

See the Enable Straiker example.

Test the plugin

Send a benign prompt:

curl -i -X POST http://localhost:8000/v1/messages \
  --header "Content-Type: application/json" \
  --data '{
    "model": "claude-sonnet-4-5-20250929",
    "max_tokens": 256,
    "system": "You are a helpful assistant.",
    "messages": [
      { "role": "user", "content": "What is the capital of France?" }
    ]
  }'

Expect HTTP 200 and x-straiker-verdict: allow.

If a request violates a blocking policy, Kong Gateway returns the policy message and the upstream model isn’t called. If the policy is in detect-only mode, the request continues, the response is stamped detect, and the event appears in the Straiker Console for review.

Keep max_tokens generous while testing. A reply truncated at stop_reason: max_tokens can look like a block.

Verdict header

The plugin stamps every response with an x-straiker-verdict header:

x-straiker-verdict

Meaning

allow Scored, nothing fired.
detect A control fired while the tenant is in detect mode. Not a block.
block Enforced. The answer was replaced.
degraded Straiker was unreachable or errored and fail_closed is false, so traffic passed uninspected.
unknown Straiker answered in an unrecognized shape. Traffic also passed uninspected.

Set up alerts on degraded and unknown. Both return a healthy-looking 200 while the control isn’t running.

Troubleshooting

Plugin not found

Symptoms: Kong Gateway returns plugin 'straiker' not enabled.

Possible solutions:

  • Confirm the plugin files are installed on every data plane node.
  • Confirm KONG_PLUGINS includes straiker and still includes bundled.
  • Restart or reload Kong Gateway after installation.
  • In Konnect hybrid mode, confirm the plugin schema was uploaded to the control plane.

426 Upgrade Required and no verdict header

Symptoms: Requests return 426 Upgrade Required with no x-straiker-verdict header.

Possible solutions:

No events in Straiker

Symptoms: Traffic passes through Kong Gateway, but nothing appears in the Straiker Console.

Possible solutions:

  • Confirm config.api_key is valid for the environment config.detect_url points at, and that data planes can reach that endpoint.
  • Temporarily set config.debug_preamble to true and look for [straiker] entries in the Kong Gateway logs, then turn it off.

Verdict is degraded or unknown

Symptoms: Responses carry x-straiker-verdict: degraded or unknown.

Possible solutions:

  • For degraded, Straiker was unreachable or returned an error. Check egress, the key, and config.timeout_ms.
  • For unknown, the response couldn’t be interpreted. Check that config.detect_url points at a supported API version.

Large multimodal requests fail

Symptoms: Requests with large inline images or PDFs fail.

Possible solutions:

  • Inline images and PDFs increase request size because they’re base64 encoded. Raise the Kong Gateway request body buffer and maximum body size.

Limitations

  • Konnect Serverless Gateways don’t support custom plugins.
  • The delivery mode is set per node, not per Route. See Delivery mode for the mode trade-offs.
  • buffered mode is incompatible with AI Proxy on streaming requests.
  • Synchronous scoring adds latency to the request path.

Security considerations

  • Attribution follows the Route’s authentication. The plugin reads the Kong Consumer when one is resolved and falls back to the static user_ref otherwise. It never reads an identity header from the client.
  • Put an authentication plugin on any Route whose attribution you rely on.
  • Store api_key and upstream_api_key as Kong Gateway Vault references. Both fields are referenceable.
  • Keep debug_preamble set to false in production. It writes prompt content to the node’s error log.
  • Use TLS egress to Straiker.
  • Alert on degraded and unknown verdicts so a degraded control is visible.
  • Start with detect-only controls in the Straiker Console before enabling blocking for production applications.
  • Review blocked and detected events regularly in the Straiker Console.

Help us make these docs great!

Kong Developer docs are open source. If you find these useful and want to make them better, contribute today!