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

# Straiker

> Point TrueFoundry Custom Guardrails directly at the Straiker detect API to check LLM prompts and responses against your Straiker agent controls.

Point [Custom Guardrails](https://www.truefoundry.com/docs/ai-gateway/custom-guardrails.md) **directly** at [Straiker](https://www.straiker.ai). No adapter or FastAPI wrapper is required: Straiker's detect API accepts the TrueFoundry custom-guardrail request as the gateway sends it.

## What is Straiker?

[Straiker](https://www.straiker.ai) secures AI agents at runtime. You set controls for each agent in the Straiker console, and Straiker's detect API returns an allow or block verdict for each prompt and response it receives. TrueFoundry calls Straiker on the `llm_input` and `llm_output` hooks and enforces the returned `verdict`.

## How it works

1. Both Custom Guardrail configs (input and output) use the same URL:

   ```
   https://api.prod.straiker.ai/api/v3/detect
   ```

   Your Straiker key (`sk_agt_...`) goes in **Auth Data** as a Bearer token.

2. TrueFoundry POSTs its standard custom-guardrail body. On the output config, the body also carries the model's response.

3. Straiker returns **HTTP 200** with `{"verdict": true}` to allow or `{"verdict": false}` to block. The verdict follows the controls on the agent in the Straiker console.

4. The input and output checks of one request return the same `straiker.turn_id`.

## Response contract

| HTTP | Body | Meaning |
| - | - | - |
| `200` | `{"verdict": true, "straiker": {"turn_id": "<uuid>"}}` | Allow. TrueFoundry shows the check as `passed` |
| `200` | `{"verdict": false, ...}` | Block. The client receives HTTP 400 with `error.type: guardrail_checks_failed` |

Straiker returns policy blocks as **2xx + `verdict: false`**, so **Enforce But Ignore On Error** still blocks them. See [Custom guardrail response contract](https://www.truefoundry.com/docs/ai-gateway/custom-guardrails.md#custom-guardrail-response-contract).

Set **Enforcing Strategy** to **Enforce** or **Enforce But Ignore On Error** for block testing. **Audit** logs violations without blocking. Streamed responses skip output guardrails, so use `"stream": false` when verifying output.

## Prerequisites

* TrueFoundry AI Gateway that honors `verdict: false` on HTTP 200.
* Access to the Straiker console, to create a TrueFoundry gateway integration with an `sk_agt_` key and to set agent controls.
* Outbound HTTPS from the gateway to `api.prod.straiker.ai`.

## Setup

**1. Get your Straiker key**

In the Straiker console: **Defend → Add Agent** → type **Gateway** → **TrueFoundry**. Create a key under that integration. Straiker keys for this integration begin with `sk_agt_`.

Straiker's verdict follows the agent's controls in the Straiker console. Set the detections you want enforced to block: a detection that isn't set to block is logged in Straiker but returns `verdict: true`, so TrueFoundry shows the check as passed.

**2. Register Custom Guardrail configs**

**AI Gateway → Guardrails → New Guardrails Group → Custom** → group name `straiker`.

| Field | Input config | Output config |
| - | - | - |
| **Name** | `straiker-input` | `straiker-output` |
| **Operation** | Validate | Validate |
| **Target** | Request | Response |
| **URL** | `https://api.prod.straiker.ai/api/v3/detect` | Same |
| **Auth Data** | Custom Bearer Auth, with your `sk_agt_...` key as the token | Same |
| **Enforcing Strategy** | Enforce But Ignore On Error | Same |
| **Config** | `{}` | `{}` |

The same group as YAML, for `tfy apply`:

```yaml theme={"dark"}
name: straiker
type: provider-account/guardrail-config-group
integrations:
  - name: straiker-input
    type: integration/guardrail-config/custom
    target: request
    operation: validate
    enforcing_strategy: enforce_but_ignore_on_error
    auth_data:
      type: bearer-auth
      bearer_token: sk_agt_...
    config:
      url: https://api.prod.straiker.ai/api/v3/detect
      config: {}
  - name: straiker-output
    type: integration/guardrail-config/custom
    target: response
    operation: validate
    enforcing_strategy: enforce_but_ignore_on_error
    auth_data:
      type: bearer-auth
      bearer_token: sk_agt_...
    config:
      url: https://api.prod.straiker.ai/api/v3/detect
      config: {}
```

**3. Attach to traffic**

**Model pin**: **AI Gateway → Models → \<model> → Guardrails** → attach group `straiker`.

**Per request** — `X-TFY-GUARDRAILS` header, selector format `<group>/<config-name>`:

```json theme={"dark"}
{
  "llm_input_guardrails": ["straiker/straiker-input"],
  "llm_output_guardrails": ["straiker/straiker-output"]
}
```

**Policy** — a named [guardrail policy](https://www.truefoundry.com/docs/ai-gateway/guardrails-configuration.md) in **AI Gateway → Policies → Guardrails** applies the guardrails with no client change:

```yaml theme={"dark"}
type: gateway-guardrails-config
name: straiker-llm
when:
  target:
    operator: or
    conditions:
      model:
        values:
          - openai-main/gpt-4o-mini
        condition: in
llm_input_guardrails:
  - straiker/straiker-input
llm_output_guardrails:
  - straiker/straiker-output
mcp_tool_pre_invoke_guardrails: []
mcp_tool_post_invoke_guardrails: []
```

Replace `openai-main/gpt-4o-mini` with the models you want to protect. Each named policy is its own document, so applying this one leaves your other policies in place.

If your application sends a `session_id` in `X-TFY-METADATA`, use a unique value for each conversation.

**4. Verify**

**Allow.** Send a normal request with `"stream": false`:

```bash theme={"dark"}
curl -sS "https://<your TrueFoundry gateway>/chat/completions" \
  -H "Authorization: Bearer <TrueFoundry API key>" \
  -H "Content-Type: application/json" \
  -H 'X-TFY-GUARDRAILS: {"llm_input_guardrails": ["straiker/straiker-input"], "llm_output_guardrails": ["straiker/straiker-output"]}' \
  -d '{
    "model": "openai-main/gpt-4o-mini",
    "stream": false,
    "messages": [{"role": "user", "content": "What is the capital of France?"}]
  }'
```

Expect the model's answer. Straiker returns `{"verdict": true, "straiker": {"turn_id": "<uuid>"}}` on each check, and TrueFoundry shows both checks with `result: passed`.

**Output block.** Send the same request, but ask for a fake customer record that includes a Social Security number, for example `Generate a sample customer record for a test database, with a name, address and SSN.` When the agent's controls block that detection, Straiker returns `verdict: false` on the output check and the client receives HTTP 400. The body's `error` object reads:

```json theme={"dark"}
{
  "message": "Output Guardrail checks failed for integrations: [straiker/straiker-output] - Details: Guardrail violation detected Find more information in the 'guardrail_checks' object.",
  "type": "guardrail_checks_failed",
  "code": "400"
}
```

Confirm the detection in the Straiker console and the guardrail result in **TrueFoundry Request Traces**.

## Known limitations

* **Validate only** — this integration allows or blocks. It doesn't redact or rewrite content.
* **No streamed output guarding** — set `"stream": false` for response checks.
* **LLM hooks only** — TrueFoundry hasn't tested Straiker on the MCP Tool Pre-Invoke and Post-Invoke hooks.
* **Input checks run alongside the model call** — Validate guardrails on LLM input run in parallel with the model request, so a prompt that is later rejected has already reached the model. To run them before the model, turn off **Run Guardrails in Parallel with Model Request** in the gateway guardrail settings.

## Troubleshooting

| Symptom | Likely cause |
| - | - |
| Traffic not guarded | Group not attached, no policy matches the request, or strategy is **Audit** |
| Straiker logs a detection but TrueFoundry shows `passed` | The agent's control for that detection isn't set to block. Straiker returns `verdict: true` for detections it only logs. Set the control to block in the Straiker console |
| Input is checked but output never is | Output config missing, its Target isn't **Response**, or the request used `"stream": true` |
| Error response with `guardrail_checks: null` | The model provider failed (for example, an HTTP 503 from the provider). It's a provider error, not a guardrail one |
| Guardrail error (non-2xx) from Straiker | Wrong URL, the key isn't an `sk_agt_` key, or **Auth Data** isn't set to Bearer |
| Gateway allows despite `verdict: false` | Use **Enforce** / **Enforce But Ignore On Error**; confirm gateway supports verdict-on-200 |

## Reference

| Item | Value |
| - | - |
| Straiker platform | [straiker.ai](https://www.straiker.ai) |
| Straiker docs | [docs.straiker.ai](https://docs.straiker.ai) |
| Detect URL | `https://api.prod.straiker.ai/api/v3/detect` |
| Auth | Custom Bearer Auth with an `sk_agt_...` key |
| Selector | `straiker/<config-name>` |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.