SDK Referencepd.render()

pd.render()

Fetch the active prompt and substitute all {{variable_name}} slots with your provided values. Returns the fully rendered prompt ready to pass to an LLM.


Signature

pd.render(slug: string, options: RenderOptions): Promise<RenderedPrompt>

Parameters

ParameterTypeRequiredDescription
slugstringYesThe prompt slug
options.env'development' | 'staging' | 'production'YesEnvironment to fetch from
options.variablesRecord<string, string>NoValues to substitute for each {{variable}}

Returns

interface RenderedPrompt {
  promptId: string       // unique prompt ID
  promptSlug: string     // the slug you passed to pd.render()
  versionId: string
  versionNumber: number
  content: string        // raw prompt text
  rendered: string       // fully rendered — all {{variables}} substituted
  role: 'system' | 'user' | 'assistant'
  model: string
  temperature: number
  maxTokens: number | null
  topP: number
  stopSequences: string[]
  variables: string[]    // the variable names that were substituted
  environment: string
}

Example

Given a prompt in the dashboard:

You are an experienced technical interviewer.
Your candidate is {{candidate_name}}, applying for a {{job_role}} role.
Difficulty level: {{difficulty}}.
const rendered = await pd.render('interviewer-system', {
  env: 'production',
  variables: {
    candidate_name: 'Eoin',
    job_role: 'Senior Engineer',
    difficulty: 'hard',
  },
})
 
console.log(rendered.content)
// → "You are an experienced technical interviewer.
//    Your candidate is Eoin, applying for a Senior Engineer role.
//    Difficulty level: hard."
 
// Pass directly to your LLM
const response = await openai.chat.completions.create({
  model: rendered.model,
  temperature: rendered.temperature,
  messages: [
    { role: rendered.role, content: rendered.content },
    { role: 'user', content: 'Tell me about yourself.' },
  ],
})

Variable validation

If your prompt declares a variable (e.g. {{candidate_name}}) and you don’t provide a value for it, the SDK throws a VersionRError:

VersionRError: Missing required variable: candidate_name
  Prompt: interviewer-system (v3)
  Declared variables: candidate_name, job_role, difficulty

This fails loudly rather than silently sending a broken prompt to your LLM.

Variables in VersionR are always {{snake_case}} — letters, numbers, and underscores only, starting with a letter.


Extra variables

Providing a variable that the prompt doesn’t declare is allowed and silently ignored. This makes it safe to pass a broad context object:

const userContext = {
  candidate_name: 'Eoin',
  job_role: 'Senior Engineer',
  difficulty: 'hard',
  session_id: 'abc123',      // not in prompt — ignored
  timestamp: '2025-01-01',   // not in prompt — ignored
}
 
const rendered = await pd.render('interviewer-system', {
  env: 'production',
  variables: userContext,
})

MIT 2026 © Nextra.