slug (e.g. ratelimit, semanticcache, cors) —
configured with settings and run at one or more lifecycle stages, with a mode,
priority, and a scope (global or per consumer).
Built-in policies
Policy (slug) | Purpose |
|---|---|
ratelimit | Per-consumer / per-gateway request rate limiting. |
tokenratelimit | Token-based limiting for LLM cost control. |
requestsize | Reject requests above a size / character budget. |
semanticcache | Embedding-based response caching for repeated prompts. |
cors | Cross-origin resource sharing for browser clients. |
Security policies. Jailbreak, PII, toxicity, and tool-abuse detection are not built into the gateway — they’re provided by TrustGuard, attached as a gateway policy. See the TrustGate integration.
Stages
A policy fires in one or more lifecycle stages:| Stage | When |
|---|---|
pre_request | Before the request is forwarded upstream. |
post_request | After the request is built, before sending. |
pre_response | After the upstream responds, before returning. |
post_response | After the response is returned (e.g. cache populate). |
pre_request and populates at post_response.
Mode
A policy’smode sets its enforcement intent:
| Mode | Behavior |
|---|---|
enforce | Reject the request on violation (default). |
throttle | Slow down but pass. |
observe | Log only — no enforcement. |
Ordering and scope
| Field | Meaning |
|---|---|
slug | The built-in capability this policy configures. |
settings | The policy’s configuration (limits, thresholds, origins…). |
priority | Lower runs earlier. |
parallel | Run alongside other policies at the same stage concurrently. |
global | Apply to all consumers in the gateway. |
enabled | Toggle without deleting. |
priority order. Policies that partition by a key (the rate limiters) 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}.