guardrails: null, which disables inspection.
Guardrails detect supported credential and sensitive-data patterns. They do not redact text or provide model-based content moderation, prompt-injection detection, or a guarantee that all sensitive data will be detected.
Configure a policy
Includeguardrails when creating a token group, or send it in PATCH /v2/llm_token_gateway/token_groups/{id}. Authenticate with a Telnyx account API key and supply the idempotency and ETag headers required for the mutation.
This PATCH body blocks supported secrets in both directions and flags financial data:
prompt and response actions:
If several rules match,
block takes precedence over flag. DLP needs at least one profile whenever either DLP action is flag or block. Unknown fields, duplicate profiles and unsupported values return 400.
Omitting guardrails from a PATCH preserves the policy. Supplying a guardrails object replaces the entire nested policy: omitted actions become ignore, and omitted DLP profiles become an empty list. Send the complete intended policy when changing one action. To disable inspection, send:
503 while the change propagates. Read the group back to verify the saved policy.
Detectors
These are pattern checks, not verification that a credential is active or an identifier belongs to a real person. Formats outside the supported patterns can be missed; text that resembles a supported format can match. Names, addresses and other free-text personal information are not detected.
The gateway inspects supported message text, system text, tool definitions and tool inputs/arguments. Response inspection includes supported text, refusal, thinking and tool-use fields. Opaque provider signatures, encrypted thinking data, provider metadata and unrecognized content-block types are outside this inspection coverage. Guardrails do not inspect images or audio.
Blocking and usage
Guardrail findings are separate from the usage ledger. Do not interpret a blocked response as a refund or automatically retry it. When a cached response is available, it is checked against the current response policy before replay; a blocked cache hit makes no provider call and creates no spend event.
Streaming
streaming accepts buffered or passthrough:
- Buffered: the gateway holds the stream until inspection completes, then replays its SSE events. This delays the first content event. Any response
blockaction requires this mode; it is selected automatically ifstreamingis omitted. Explicitpassthroughwith a responseblockaction is rejected with400. - Passthrough: events are forwarded immediately and findings are evaluated after the stream completes. This mode cannot block responses. It is the default when no response action is
block.
data: event containing the error document. For Anthropic Messages, it is an event: error frame. Handle stream errors even when the initial HTTP status was 200.
Flagged-response header
Successful responses with flagged findings can includex-ltg-policy. Its value is JSON containing detector codes, counts and actions:
Query findings
UseGET https://api.telnyx.com/v2/llm_token_gateway/guardrail_events with the Telnyx account API key. Only that account’s events are returned, newest first. Events identify the request, token key, group, optional user/end user, model, stage, outcome and findings. Findings contain codes and counts, never matched text or prompt/response excerpts.
The response contains
data and meta.page_number, meta.page_size, meta.has_more. Unlike resource and spend listings, guardrail events use offset pagination and do not accept page[snapshot]. Newly inserted events can shift page boundaries; deduplicate by event id when collecting several pages.
A findings-storage failure does not make a blocked request pass, but it can leave no event for that decision. Use the inference error and X-Request-ID as well when investigating a blocked request.