Skip to main content
A policy is a named set of guardrails. A policy can build on a base policy, and add guardrails to it or remove some. Attachments say where each policy applies. POST /v2/agent_gateways/{id}/policies creates one. This policy runs the guardrails of baseline and a custom code check, on requests for GLM-5.3-Flash:

Inheritance

A policy that builds on a base policy starts with the base’s guardrails, then adds and removes its own. A strict policy can build on a baseline policy that masks personal data, and add a custom code check, so both run.

Conditions

A policy can apply only to some models, named exactly or by a regular expression. Its guardrails then run only on requests for those models.

Attachments

POST /v2/agent_gateways/{id}/policy_attachments applies a policy to every request, or to requests for the models it names. A model name in an attachment can use * as a wildcard:
An attachment with a priority applies before the others. A default attachment, with "default": true, applies only to the requests that no other attachment matches. A request can also add policies by name, in policies:
Like a guardrail, a policy only adds checks. It cannot turn off a guardrail that runs on every request.

Pipelines

A policy can run its guardrails as ordered steps instead. Each step says what happens when its guardrail passes, fails, or errors:
  • next goes on to the next step.
  • allow allows the request.
  • block blocks the request.
  • respond replaces the response with the step’s message.
A policy that is named by an attachment, or that another policy builds on, cannot be deleted.