Skip to main content
A policy attaches behavior to a gateway’s traffic. Each policy configures one built-in plugin — identified by its slug (e.g. rate_limiter, semantic_cache, cors) — with settings, and runs at one or more lifecycle stages, with a mode, priority, and a scope (global or per consumer).
A policy’s slug is the plugin name it configures — always the underscore form (rate_limiter, token_rate_limiter, request_size_limiter, semantic_cache, …). Browse the live catalog and its settings schema at GET /v1/policies-catalog.

Built-in policies

TrustGate ships 16 built-in plugins, grouped by purpose:

Traffic control

Policy (slug)Purpose
rate_limiterPer-consumer / per-gateway request rate limiting (sliding window).
request_size_limiterReject requests above a byte / character budget.
per_tool_rate_limiterRate-limit individual tool calls observed in responses.
corsCross-origin resource sharing for browser clients.

Quota & cost

Policy (slug)Purpose
token_rate_limiter (“LLM Budget”)Token or dollar budgets over time windows, aggregate or per-model.
cost_cap (“LLM Cost Cap”)Per-request guard on a model’s list price per 1k tokens.

Routing

Policy (slug)Purpose
semantic_cacheExact or embedding-similarity response caching.
model_allowlistRestrict which models a consumer/gateway may call.
tool_allowlistAllow/deny the tools in a request tools[] array.

Prompt management

Policy (slug)Purpose
prompt_templateInject context-bound system prompts and render named, versioned templates.

Tool governance

Policy (slug)Purpose
tool_call_validationValidate / redact the tool calls a model returns.
tool_definition_transformationPatch tool schemas, override descriptions, and inject tools.

Guardrails

Policy (slug)Purpose
trustguardInspect prompts/responses with TrustGuard (jailbreaks, PII, toxicity, tool abuse).
openai_moderationScreen text with the OpenAI Moderations API.
azure_content_safetyScreen text with Azure AI Content Safety.
bedrock_guardrailApply an AWS Bedrock guardrail (topics, content, PII, grounding).
NeuralTrust-native detection. The gateway ships several guardrail plugins, but the deepest jailbreak / PII / toxicity / tool-abuse detection is TrustGuard, attached via the trustguard policy. See the TrustGate integration.

Stages

A policy fires in one or more lifecycle stages:
StageWhen
pre_requestBefore the request is forwarded upstream.
pre_responseAfter the upstream responds, before returning to the client.
post_responseAfter the response is returned (e.g. cache populate, budget accrual).
Some policies span two stages — the semantic cache looks up at pre_request and populates at post_response; the LLM Budget checks at pre_request and accrues usage at post_response. (A post_request stage exists in the model but is not executed on the proxy forward path.)

Mode

A policy’s mode sets its enforcement intent. Not every plugin supports every mode:
ModeBehavior
enforceAct on violations — reject, transform, or block (default).
throttleDelay rather than reject (supported by the rate/budget plugins).
observeRecord only — no enforcement.

Ordering and scope

FieldMeaning
slugThe built-in plugin this policy configures.
settingsThe policy’s configuration (limits, thresholds, origins…).
priorityLower runs earlier.
parallelRun alongside other same-priority policies concurrently.
globalApply to all consumers in the gateway.
enabledToggle without deleting.
Global policies are the gateway-wide baseline (e.g. a default request-size guard); consumer-scoped policies tune behavior per tenant. The proxy resolves both sets and runs them in priority order. When same-priority policies run in parallel, only one may mutate a given part of the request/response per batch. Policies that partition by a key (the rate limiters and budgets) also accept a group_by_header to sub-partition within scope.

Managing policies

CRUD lives under /v1/gateways/{gateway_id}/policies, plus:
  • …/{id}/global (POST/DELETE) — promote/demote to global.
  • …/{id}/duplicate (POST) — clone a policy.
  • Attach to a consumer via …/consumers/{id}/policies/{policy_id}.
See the Policies API.