Skip to content

Variables

A prompt body carries placeholders written as {{name}}. The server substitutes them from the vars you pass and returns the finished text.

text
Reply to {{customerName}} about {{topic}}.
ts
await client.prompts.resolve("support-reply", {
  vars: { customerName: "Ada", topic: "billing" },
});

The rules, and why they are these rules

  • A missing variable fails the call with 400 VALIDATION_ERROR. The alternative — substituting an empty string — ships a prompt with a hole in it to your model, and you find out from the output rather than from the error.
  • Unknown keys are ignored. Passing more than the prompt uses is not an error, which is what lets you hand the same context object to several prompts and lets a prompt drop a variable without breaking its callers.
  • Values are substituted literally. They are not parsed, not re-scanned for further placeholders, and not trimmed. A value containing {{x}} stays that text.
  • Everything is a string. Format numbers and dates yourself, where the formatting decision belongs.

Variables in BRAID graphs

A version can carry a BRAID graph instead of, or alongside, classic prompt text. Node labels use the same {{name}} syntax and the same rules — the grammar has a single definition shared by the app, the server and the SDK, so what the editor accepts is what the server resolves.

Released under the MIT licence.