Skip to content
An 8-bit-style flat icon features a geometric speech bubble containing code brackets and a dollar sign, symbolizing coding or template expressions. Around the bubble are small, simple blocks and circles representing variables and template elements, all rendered in a clean, minimal, five-color corporate palette on a transparent background, using only basic geometric shapes. The image excludes people, text, shadows, gradients, or 3D effects.

Prompt ($)

The $ is a JavaScript tagged template that expands the string into the final prompt.

example.genai.mjs
$`You are a helpful assistant.`
👤 user
You are a helpful assistant.

You can weave expressions in the template using ${...}. Expressions can be promises and will be awaited when rendering the final prompt.

example.genai.mjs
$`Today is ${new Date().toDateString()}.`
👤 user
Today is Thu Jun 13 2024.

The output of the $ can be further processed by running popular jinja or mustache template engines.

$`What is the capital of {{ country }}?`.jinja(env.vars)
$`What is the capital of {{ country }}?`.mustache(env.vars)

When running an inline prompt, you can use the $ to generate the prompt dynamically but you need to call it on the generation context.

example.genai.mjs
const res = await runPrompt(ctx => {
ctx.$`What is the capital of France?`
})