pd.get()

Fetch the active prompt for a given environment. Returns the raw prompt content and its metadata without performing variable substitution.

Use pd.get() when you want to handle variable substitution yourself, or when your prompt has no variables.


Signature

pd.get(slug: string, options: GetOptions): Promise<Prompt>

Parameters

ParameterTypeRequiredDescription
slugstringYesThe prompt slug, as set in the dashboard
options.env'development' | 'staging' | 'production'YesThe environment to fetch from

Returns

interface Prompt {
  promptId: string       // unique prompt ID
  promptSlug: string     // the slug you passed to pd.get()
  versionId: string
  versionNumber: number
  content: string        // raw prompt text, with {{variables}} unsubstituted
  role: 'system' | 'user' | 'assistant'
  model: string          // e.g. "gpt-4o"
  temperature: number
  maxTokens: number | null
  topP: number
  stopSequences: string[]
  variables: string[]    // detected variable names
  environment: string
}

Example

const prompt = await pd.get('interviewer-system', { env: 'production' })
 
// Use the versioned model and temperature
const response = await openai.chat.completions.create({
  model: prompt.model,
  temperature: prompt.temperature,
  messages: [
    { role: prompt.role, content: prompt.content },
    { role: 'user', content: userMessage },
  ],
})
 
// Log the result
await pd.log({
  promptId: prompt.promptId,
  promptSlug: prompt.promptSlug,
  versionId: prompt.versionId,
  versionNumber: prompt.versionNumber,
  environment: 'production',
  renderedPrompt: prompt.content,
  output: response.choices[0]?.message.content ?? '',
  latencyMs: Date.now() - startTime,
  tokens: {
    prompt: response.usage?.prompt_tokens ?? 0,
    completion: response.usage?.completion_tokens ?? 0,
  },
})

Notes

  • The model and temperature are versioned alongside the prompt text. Using prompt.model and prompt.temperature ensures your app always uses the configuration that was tested with that version.
  • If the environment has no deployed version, the SDK throws a VersionRError with code NO_ACTIVE_VERSION.
  • Responses are cached in memory for the duration of the process. See Error Handling & Caching.
💡

If your prompt contains {{variables}}, use pd.render() instead to have them substituted automatically.


MIT 2026 © Nextra.