Skip to main content

Guardrails

A guardrail is a rule your organization’s admins configure in the console. It runs inside Prism on every chat, messages, embeddings, and image request, either before the prompt reaches the provider or after the response comes back, and it can block the request, rewrite the text, or record what it saw. This page is for developers calling the API: what a rule can do to your request and how to tell.

What a rule can do

Built-in checks: regular expression match and replace, personal data masking (emails, Thai phone numbers, card numbers, Thai national ids, IBANs), JSON schema validation of a response, word and character counts, a model allowlist, and a webhook to your own service.

Streaming responses

Rules that run after the response run on a streamed body only in log mode. The bytes have already been sent by the time the stream ends, so a deny or mask rule cannot apply to a stream. When a deny rule on the response applies to your route and model, a request with stream: true is refused up front with 400 guardrail_requires_non_streaming; send stream: false instead. Response rules only see text content, so a response that carries only tool calls is not inspected.

Reading the result

A denied request returns:
details.checks from the built-in checks never contains your prompt or the response text, only what the check reported about them. A webhook rule’s data is whatever your organization’s own endpoint returned.

Limits

A rule that cannot finish in time, or a webhook that does not answer, counts as error and the request continues; your admins can choose to fail closed instead, in which case a deny or mask rule that could not run refuses the request. Each request has a budget for how much text its rules may inspect (by default 131,072 characters across all messages); past it the rules are skipped, or the request is refused when the deployment fails closed. A rule edit takes up to a minute to reach every request. Guardrails are available when the deployment has enabled them. อ่านภาษาไทย