pre_request.
Create them under Policies → Catalog, or attach them from a consumer Policies
tab. Scope each policy gateway-wide or targeted.
Protocol: LLM only.
To restrict which models a consumer may call, use the consumer Routing tab
(Filter by available models / default model) — not a catalog policy. See
Model resolution.
Prompt Template
prompt_template runs at pre_request and rewrites the chat body using
Mustache-style {{placeholders}} (v1 engine: mustache
only).
The console form has two modes. The UI edits one mode at a time; config for the other
mode is preserved if you switch.
You must configure at least one inject template or one named template (backend
validation).
Configure in the console
- Policies → Catalog → Prompt Template.
- Choose Mode: Auto-inject or Named templates.
- Add templates (details below).
- Set If a variable is missing (Reject request / Use empty string).
- Optionally open Advanced Settings (escape JSON control characters).
- Set mode (Enforce / Observe) and scope, then save.
Mode A — Auto-inject
Gateway renders each inject template from context variables and writes a system message into the request.
Placeholders must match
{{name}} where name is letters, digits, ., -, or _
(e.g. {{user_id}}, {{tenant.name}}).
Context variables (context_variables) map placeholder names to request data:
The console does not yet expose a full context-variable editor; values configured via API
or existing policies are preserved. When a placeholder cannot be resolved:
The shared UI control writes the same choice to both
on_missing_context_variable and on_missing_client_variable (client supports
error / empty_string only).
Mode B — Named templates
Clients reference a template in a plain string user message (not multimodal content parts):
Resolution rules
- Scan user message string content for
{template://name}or{template://name@label}. - Exactly one distinct reference per request (repeats of the same ref are OK for multi-turn).
- Resolve name → template, then label (or default label) → version.
- Render placeholders from client variables (request
properties/ template vars) and context variables. - Replace the entire
messagesarray with the rendered content (not a single-message patch). Multi-turn history sent by the client is discarded when rendering succeeds.
required_variables (type / enum / max_length) can be set via API;
the console preserves them if present.
Advanced
Example (auto-inject)
Example (named template client call)
Prompt Compression
prompt_compression shrinks the request prompt on pre_request before the model runs.
Transforms are deterministic (same input → same bytes) so provider prompt-cache
prefixes stay stable, and the plugin fails open: any decode/transform error leaves the
original body unchanged.
The console uses the catalog settings schema form (booleans, integers, role multi-select).
Configure in the console
- Policies → Catalog → Prompt Compression.
- Enable at least one transform (defaults are all on).
- Tune thresholds and optional target roles.
- Set mode and scope, then save.
Settings
At least one of compress JSON / normalize whitespace / strip ANSI must stay enabled.
Example
Related
- Policies overview
- Model resolution — filter models and defaults on the consumer
- Consumers — Routing tab model filters
- Playground — exercise template behaviour