Skip to main content

Policy Hub

The Policy Hub is the official, curated collection of gateway policies. It gives you a growing library of production-ready, versioned policy implementations that you can apply to any API without writing custom code.

Policies are self-contained units of behavior that plug into the gateway's request and response pipeline. You compose them, like stacking authentication on top of rate limiting on top of a guardrail, as opposed to building each concern from scratch. If your requisites exceed what the hub provides, you can author and ship your own policies alongside hub ones.

The Policy Hub is powered by an open source repository on GitHub. Every policy is versioned independently, the full source and documentation live in the repo, and contributions are welcome. For more information about contributing policies, see Policy Development Guide.

How Policies Work​

A policy attaches to an API, covering all operations, or to a specific operation, and runs on the request phase, the response phase, or both. Multiple policies chain together on the same API, each one processing the message in sequence before it reaches the next. The gateway evaluates the chain at runtime.

For more information, see Policies.

Policy categories​

Security​

Authenticate incoming requests and secure outbound calls to your backend, using mechanisms such as API keys and OAuth 2.0 (OAuth2).

PolicyWhat it does
API Key AuthProtects APIs with pre-shared API keys
Basic AuthEnforces HTTP Basic Authentication
JWT AuthValidates JWT access tokens against one or more JWKS providers
OAuth2 GeneratorGenerates an OAuth 2.0 or static bearer credential and injects it into a configurable request header before forwarding to the backend
CORSHandles preflight requests and injects CORS response headers
Subscription ValidationConfirms the caller holds an active subscription for the target API
Rate Limit - BasicCaps requests per time window
Rate Limit - AdvancedMulti-dimensional quotas with GCRA or fixed-window algorithms, Redis backend support, and weighted limiting

Guardrails​

Control what goes into and out of AI models. Guardrail policies block unsafe prompts in the request pipeline before they reach a model. In the response pipeline, they filter unsafe or non-compliant output before it reaches the caller.

PolicyWhat it does
AWS Bedrock GuardrailValidates content against AWS Bedrock Guardrails
Azure Content SafetyScreens content against Azure Content Safety API
Semantic Prompt GuardBlocks or allows prompts based on semantic similarity to configured allow/deny phrases
PII MaskingMasks or redacts PII from request/response bodies using configurable regex patterns
JSON Schema GuardrailEnforces a JSON Schema on request or response payloads
Regex GuardrailValidates content against a regular expression
URL GuardrailValidates URLs found in request or response bodies
Content Length GuardrailEnforces byte-length limits on payloads
Word Count GuardrailEnforces word-count limits on payloads
Sentence Count GuardrailEnforces sentence-count limits on payloads

AI and LLM​

Policies designed specifically for the characteristics of AI APIs - cost, tokens, latency, and prompt structure.

PolicyWhat it does
LLM CostCalculates the monetary cost of each LLM call and stores it for downstream policies
LLM Cost-Based Rate LimitEnforces monetary budget quotas on LLM usage
Token-Based Rate LimitCaps usage by token count rather than request count
Semantic CacheCaches LLM responses using vector similarity, returning cached results for semantically equivalent prompts
Prompt DecoratorInjects system instructions or context into prompts at the gateway layer
Prompt TemplateApplies configurable templates to transform prompts before they reach the model
Prompt CompressorCompresses prompt text to reduce token usage before upstream calls
Model Round RobinDistributes requests evenly across a pool of AI model endpoints
Model Weighted Round RobinDistributes requests across model endpoints according to configured weights
RespondReturns an immediate response without forwarding to the upstream backend

Transformation​

Modify requests and responses in flight.

PolicyWhat it does
Request RewriteRewrites path, query parameters, and HTTP method before forwarding upstream
Host RewriteOverrides the Host/:authority header sent to the upstream
Dynamic EndpointRoutes a request to a named upstream at runtime
Set HeadersAdds or overwrites headers on requests or responses
Remove HeadersStrips specified headers from requests or responses
JSON/XML MediatorConverts payloads between JSON and XML formats
Interceptor ServiceCalls a user-defined HTTP service during the request and/or response phase

Logging, Analytics, and Monitoring​

PolicyWhat it does
Log MessageLogs request/response payload and headers
Analytics Header FilterControls which headers appear in analytics data using allow or deny mode

Common Use Cases​

AI guardrails: Stack prompt-injection detection, PII Masking, and a Semantic Prompt Guard on an LLM API to enforce safety and compliance requirements.

LLM cost governance: Combine the LLM Cost policy with LLM Cost-Based Rate Limit to define cost constraints that the gateway enforces transparently.

Semantic caching: Place the Semantic Cache policy on a high-traffic LLM API to serve cached responses for semantically equivalent questions, cutting both latency and cost.

Multi-model routing: Use Model Weighted Round Robin to distribute traffic across model endpoints by weight.

Independent Versioning​

Every policy in the hub is versioned on its own track. When a new version ships, prior versions remain available, so existing deployments do not break.

Was this page helpful?