Skip to main content
Prompts in Output live in .prompt files inside a prompts/ folder — version-controlled, reviewable, and deployed with your code. No more strings scattered across your codebase or prompts locked in external dashboards.
generate_summary@v1.prompt
A prompt file has two parts: YAML frontmatter (configuration) and a body containing either role-tagged messages or plain instructions.

File Naming

Prompt files use the pattern name@version.prompt:
  • generate_summary@v1.prompt
  • judge_summary@v1.prompt
  • classify_lead@v2.prompt
The version lets you iterate on prompts while keeping old versions around. When you reference a prompt in code, use the name without the .prompt extension:
Output searches recursively from your workflow’s directory to find the prompt file.

File Organization

Place prompt files in a prompts/ subfolder within your workflow directory:
The recursive search means you can also keep prompts alongside your workflow code if you prefer a flatter structure. For prompts used by multiple workflows, create a shared prompts/ folder at a higher level.

Frontmatter

The YAML frontmatter configures the LLM call.

Required Fields

Optional Fields

All fields use camelCase. Unknown top-level keys throw. A snake_case alias of a known field fails with a suggestion (max_tokens -> use maxTokens). Provider-specific keys such as effort, reasoningEffort, and topP belong under providerOptions, not at the top level.

Configuration Structure

Prompt configurations have two layers: 1. Top-level config — Standard AI SDK options:
2. providerOptions — Provider-specific and special options:
When to use providerOptions:
  • Provider-specific options that aren’t standard across all providers
  • Special AI SDK extensions like thinking or order (AI Gateway)
  • Multi-provider configurations (Vertex with multiple model types)
When NOT to use providerOptions:
  • Shared top-level fields: temperature, maxTokens, maxSteps, skills, tools, messageOptions, and the image fields (n, size, aspectRatio, seed, maxImagesPerCall)
  • These go at the top level alongside provider and model

Provider Options

Use providerOptions for provider-specific configuration. Anthropic-specific options:
OpenAI-specific options:
Google Vertex with Gemini (important namespace note):
Extended thinking (special top-level key):
Common Provider Options Reference: Google Vertex Provider Namespace Guide: When using provider: google-vertex (or the legacy alias vertex), the providerOptions namespace depends on the model:
  • Gemini models → Use google: namespace
  • Claude models → Use anthropic: namespace
  • Vertex-specific options → Use vertex: namespace

Prompt Body Modes

After rendering the template, Output determines how to parse the body from its first meaningful token. Leading whitespace and HTML comments (<!-- ... -->) do not affect this decision:
  • If the first meaningful token is plain text, the whole trimmed body becomes instructions and messages is empty. Tags later in the body stay part of the instruction text.
  • If the first meaningful token is a tag, Output enters message mode and validates the body as role-tagged markup. instructions is null.
Use instruction mode for image prompts or when consuming loadPrompt() results directly. generateText, generateTextWithStreaming, streamText, and Agent require message mode.
Use message mode when the provider should receive a conversation:
In message mode:
  • Top-level tags must be <system>, <user>, or <assistant>.
  • Between top-level blocks, only whitespace and HTML comments are allowed.
  • Top-level self-closing tags and closing tags without an opening block are invalid.
  • Every top-level block needs a matching closing tag.
  • Tags with a different name inside a message are preserved as message content. This includes semantic tags, HTML-like examples, and code such as Array<string>.
  • A nested non-self-closing tag with the same name as its message is ambiguous and throws. Escape literal examples, including both brackets, such as &lt;user&gt;example&lt;/user&gt;.
These rules are validated when the prompt loads. Invalid roles, root text, malformed attributes, and unclosed blocks produce explicit errors instead of being silently ignored.

Message Blocks

Message blocks use XML-style tags to define the conversation structure.

<system>

The system message sets the persona and constraints. It defines who the LLM is and how it should behave. This stays constant across requests.

<user>

The user message is the actual request — what you want right now. This typically contains your variables.

<assistant>

The assistant block is for conversation history or response prefilling. Use it when you want to prime the model’s response format. generateText, generateTextWithStreaming, and streamText send it as part of the prompt thread. Agent drops authored <assistant> blocks; it only seeds <user> turns (system goes to instructions). For Agent few-shot or prefills, put examples in <system> or <user>, or use generateText.
Authored <tool> blocks are not supported. AI SDK tool results use structured message parts tied to a preceding tool call; AI SDK creates these during tool execution, and Agent callers may supply them through messages or messageStore.

options

The only supported attribute on a role tag is options, a space-separated list of names from frontmatter messageOptions. At load, those sets are merged from left to right onto the message as providerOptions; later sets win when the same provider option is repeated. Give options an explicit quoted or unquoted value, such as options="cached fast" or options=cached. Bare options throws, while options="" is treated as absent. Every referenced name must exist in messageOptions, and any other role-tag attribute throws. See Prompt Caching.

System vs User

A common mistake is putting everything in the user message. The split matters: System message (constant):
  • Who the LLM is (“You are a sales research assistant”)
  • Behavioral constraints (“Never make up information”)
  • Output format requirements (“Respond in JSON”)
User message (varies per request):
  • The specific request
  • The data to process
  • Dynamic instructions based on input
This separation makes prompts easier to maintain. When you need to change the task, you edit the user message. When you need to change behavior, you edit the system message.

Using Prompts

Call prompts from your steps using the generate functions from @outputai/llm.

With generateText

For single-shot LLM calls, use generateText:
steps.ts
generateText also supports skills for on-demand instruction loading. List skill paths in the prompt frontmatter. Set maxSteps in the same frontmatter when the default of 10 is wrong.

With Agent

For multi-step tool loops and stateful conversations, use the Agent class:
steps.ts
Use generateText for single-shot LLM calls. Use Agent when you need multi-step tool execution, conversation history, or a reusable agent instance. See the Agents section for the full API. The variables object maps to the {{ variable }} placeholders in your prompt. For dynamic content like conditionals and loops, see Templating.