# Prompt templates

> A prompt template keeps instructions, a template body with placeholders, its variables, the expected output fields and examples in one record. The ai.prompt node fills it with workflow data.

Source: https://docs.sommatic.ai/en/ai/prompt-templates/ (updated 2026-11-26)

A prompt template takes the prompt out of the workflow. Whoever tunes the wording edits the template; the workflow keeps
pointing to the same record and picks up the change on its next run.

## What a template holds

| Field                         | What it is                                                                                       |
| ----------------------------- | ------------------------------------------------------------------------------------------------ |
| `slug`, `name`, `description` | Stable key and labels.                                                                           |
| `organization_id`             | Owner organization.                                                                              |
| `llm_provider_id`             | The [LLM provider](https://docs.sommatic.ai/en/ai/llm-providers.md) the template is written for. |
| `language`, `format`          | Language of the prompt and format of the expected answer.                                        |
| `system_instructions`         | The system part of the prompt.                                                                   |
| `template_body`               | The prompt text, with placeholders such as `{{ customer_name }}`.                                |
| `variables`                   | The placeholders the body expects.                                                               |
| `output_fields`               | The fields the answer should contain.                                                            |
| `style_guidelines`            | A list of style rules.                                                                           |
| `examples`                    | Worked examples of input and expected output.                                                    |
| `tags`, `is_system`           | Labels, and whether the template is a system template.                                           |

Statuses: `enabled`, `review`, `deprecated` and `archived`.

### Variables

Each entry of `variables` describes one placeholder:

```json
{
  "name": "customer_name",
  "type": "string",
  "description": "Name used in the greeting",
  "required": true,
  "default_value": "customer",
  "allowed_values": []
}
```

### Output fields and examples

An output field has `name`, `type`, `description` and `required`. An example has `inputs`, `expected_output` and
`notes`. They document the contract of the template for whoever writes or reviews it.

## Fill a template in a workflow

The [`ai.prompt`](https://docs.sommatic.ai/en/nodes/ai.prompt.md) node reads a template and returns the finished prompt.

1. Set `template_id` to the id of the template.
2. Pass `variables`, an object whose keys match the placeholders.
3. The node replaces every `{{ key }}` of `template_body` (spaces inside the braces are allowed) with its value.

With this template body:

```text
Summarize the request from {{ customer_name }} in {{ language }}, in three bullet points.
```

and this node configuration:

```json
{
  "template_id": "<prompt-template-id>",
  "variables": {
    "customer_name": "{{ $json.sender.name }}",
    "language": "Spanish"
  }
}
```

the node returns:

```json
{
  "prompt": "Summarize the request from Ana Ruiz in Spanish, in three bullet points.",
  "config": {
    "provider": "<llm-provider-slug>",
    "model": "<deployment-name>",
    "language": "<template-language>",
    "format": "<template-format>"
  }
}
```

`config.provider` and `config.model` come from the template's LLM provider (its `slug`, and its `deployment_name` or
`default_parameters.model`); `config.language` and `config.format` come from the template. The next node reads the prompt with `{{ $json.prompt }}`.

> **Note: Templates have no version history**
>
> The node always reads the current template. A change to `template_body` reaches every workflow that uses the template
> on its next run. Placeholders without a value in `variables` stay in the text as they are.

## Manage templates

In the portal, go to **Advanced → Cognitive Infrastructure → Prompt Template**. Through the API, use
`/cognitive-infrastructure/cognitive-assets/prompt-template/` (see the
[API reference](https://docs.sommatic.ai/en/api/reference/cognitive-infrastructure.md)).

## Next steps

- [Knowledge resources](https://docs.sommatic.ai/en/ai/knowledge-resources.md): Ground AI nodes on governed content.
- [Expressions](https://docs.sommatic.ai/en/expressions.md): Fill variables with data from earlier nodes.
