Content Template
Wrap request messages or LLM responses using a configurable template string.
Content Template wraps request messages or LLM responses using a configurable template string. Use this module to standardize prompts at the infrastructure level, add consistent instructions around user messages, or wrap LLM responses into a desired format — without touching your application code.
The template uses a single interpolation variable: {{ content }}, which is replaced with the full content being processed at runtime.
Stages
| Stage | What {{ content }} refers to |
|---|---|
| PRE | Each individual user message in the request |
| POST | The entire LLM response string |
| PRE + POST | Applied in both directions with the same template |
Configuration
Content Template
The template string to apply. Must contain {{ content }} (spaces around the variable name are optional) as the placeholder — if omitted, the module has no effect and a warning is logged.
Spaces are optional
{{ content }}, {{content}}, and {{ content }} are all equivalent.
Examples
Add a system instruction to every user message (PRE stage)
You are a helpful assistant. Answer concisely and in plain text only.
User input:
{{ content }}Original user message: What is the capital of France?
After template:
You are a helpful assistant. Answer concisely and in plain text only.
User input:
What is the capital of France?Wrap LLM response in a JSON envelope (POST stage)
{
"source": "infralo-gateway",
"response": "{{ content }}"
}Original LLM response: The capital of France is Paris.
After template:
{
"source": "infralo-gateway",
"response": "The capital of France is Paris."
}Add output formatting constraints (PRE stage)
{{ content }}
Instructions:
- Respond in valid JSON only.
- Do not include any explanatory text.
- Use the exact field names specified in the question.Behavior Notes
- In the PRE stage, the template is applied to each user message individually. If a request contains multiple user turns, each is wrapped independently.
- In the POST stage, the template is applied to the full LLM response string as a single unit.
- If the template does not contain
{{ content }}, the module logs a warning and passes the content through unchanged — it does not raise an error.
Example Use Cases
- Centralized prompt engineering: Standardize the instruction preamble or output format requirements across all requests in a deployment without modifying individual applications.
- Response enveloping: Wrap LLM responses in a consistent structure expected by a downstream API or service.
- Output format enforcement: Append formatting instructions to every user message to consistently guide the LLM's output style.
- Multi-tenant instructions: Inject tenant-specific instructions or context at the deployment level.