SDK ReferenceInstallation

Installation

Install the package

npm install versionr

Initialize the client

import { VersionR } from 'versionr'
 
const pd = new VersionR({
  apiKey: process.env.VERSIONR_API_KEY,
})

Store your API key in an environment variable — never hardcode it.

Configuration options

OptionTypeDefaultDescription
apiKeystringRequired. Your project API key.
baseUrlstringhttps://api.versionr.aiAPI base URL. Override if self-hosting.
defaultEnvstring'production'Default environment for all calls.
timeoutnumber5000Request timeout in milliseconds.
cachebooleantrueEnable in-memory prompt caching.
const pd = new VersionR({
  apiKey: process.env.VERSIONR_API_KEY,
  defaultEnv: 'production',
  timeout: 3000,
})
⚠️

Edge functions & serverless: If you’re using the SDK in a Supabase Edge Function, Cloudflare Worker, or similar runtime, you must set VERSIONR_BASE_URL as an environment variable (or pass baseUrl to the constructor). Without it, the SDK defaults to https://api.versionr.ai — which requires your DNS to be configured. See the Deno & Edge Functions guide for details.

Next steps

  • pd.get() — fetch the active prompt for an environment
  • pd.render() — fetch and render a prompt with variables
  • pd.log() — log results back to VersionR

MIT 2026 © Nextra.