promptTemplate is a Handlebars string. At request time it’s evaluated against the caller’s input, and the result becomes the prompt sent to the base model. This is where a wrapper earns its keep: callers type a few plain fields, and your template assembles them into a consistent, well-engineered prompt.
{ "subject": "a fox", "mood": "noir" }, this renders:
What’s available in the template
A few behaviors to keep in mind:
- Missing variables render empty. A reference to a field the caller didn’t send produces an empty string, not an error. Design templates that read cleanly when optional fields are absent.
- Output is not HTML-escaped (
noEscapeis on). Quotes, ampersands, and angle brackets pass through verbatim — exactly what you want for a prompt string. - Templates are capped at 50 KB. More than enough for a prompt recipe; if you’re approaching it, move data into
templateContext.maps.
Helpers
Only these five helpers are available. Anything else is unsupported.Conditionals
Combine helpers with Handlebars’ built-in#if to branch:
exists is the one to reach for when guarding optional fields — #if alone treats an empty string as truthy in some cases, while exists correctly skips both null and "".
Lookup maps and constants
templateContext holds data your template references — keeping the template itself short and readable.
lookup (for maps) or a direct reference (for constants):
maps when an enum field should expand into richer phrasing — moods, styles, shot types — especially when the same template structure serves many enum values. Use constants for static text you repeat, like a negative-prompt suffix. Skip templateContext for one-off values that read fine inline.
What’s not allowed
These Handlebars constructs are rejected when you create or update the wrapper — they compile but would silently render empty, so the engine fails loudly instead:
The common mistake is hardcoding a big lookup table as inline conditionals or a partial. Don’t — put enumerated values in
templateContext.maps and read them with {{lookup maps.group key}}.
Test before you ship
Usepreview_wrapper (from your AI assistant, or the studio’s live preview) to render the template against a sample input and confirm the prompt looks right — including how it reads when optional fields are omitted. Preview is the fastest way to catch a missing comma, an unmatched mood key, or a conditional that fires when it shouldn’t.
The template produces the prompt string only. Non-prompt fields the base model needs (counts, sizes, formats) come from your field mappings, not the template.

