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
id
: A unique identifier for the rule.when
: Defines the subset of requests on which the rule applies. If set to an empty object ({}
), the rule applies to all requests.
hrithik@truefoundry.com
. This rule will only apply to requests originating from this user.input_guardrails
: An array of selectors of guardrail integrations to apply to the input prompt. In this example, we are applying the OpenAI guardrail integration to the input prompt.output_guardrails
: An array of selectors of guardrail integrations to apply to the LLM response. In this example, we are not applying any guardrail integrations to the LLM response.id
: A unique identifier for the rule
when
: Defines the subset of requests on which the rule applies. If set to an empty object ({}
), the rule applies to all requests.
user:email@example.com
, team:team-name
, or virtual-account:account-name
.model
field.metadata: { environment: "production" }
will apply the rule only if the request includes the header X-TFY-METADATA
with environment=production
.input_guardrails
: An array of selectors of guardrail integrations to apply to the input prompt
output_guardrails
: An array of selectors of guardrail integrations to apply to the LLM response
Copy Guardrail Selector