when
block. The when
block allows you to target specific models, users, or request metadata, ensuring that the appropriate guardrails are applied only to relevant requests.
You can create a guardrail config by navigating to the AI Gateway -> Config Tab -> Guardrails Section -> Create/Edit Guardrail Config.
Create/Edit Guardrail Config
name
:guardrails-config
.
type
:gateway-guardrails-config
. It tells the TrueFoundry platform that this YAML file defines a guardrail configuration.
rules
:id
:when
:user:john@example.com
matches requests made by that user.team:team-name
or virtual-account:account-name
to match requests from a specific team or virtual account.metadata: { environment: "production" }
matches only if the request includes the header X-TFY-METADATA
with environment=production
.when
is {}
(empty), the rule matches all requests.
In summary:john@example.com
because the when
block specifies subjects: [user:john@example.com]
. If you add models
or metadata
fields, the rule will only match requests that satisfy all specified conditions. If a field is omitted, it is not used for filtering.input_guardrails
:output_guardrails
:Copy Guardrail Selector