SDK ReferenceOverview

SDK Overview

The VersionR SDK is the primary way your application fetches and logs prompts at runtime.

npm install versionr

TypeScript is fully supported — all methods are typed.


Initialisation

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

Create one instance and reuse it across your application. The client handles caching, retries, and fallbacks internally.

Options

OptionTypeRequiredDescription
apiKeystringYesYour project API key from the dashboard
baseUrlstringNoOverride the API base URL (default: https://api.versionr.ai)
cachebooleanNoEnable in-memory fallback cache (default: true)
timeoutnumberNoRequest timeout in milliseconds (default: 5000)

Methods

MethodDescription
pd.get()Fetch the active prompt content for an environment
pd.render()Fetch and render a prompt with variable substitution
pd.log()Log a result back to VersionR

⚠️

Never commit your API key. Use environment variables: process.env.VERSIONR_API_KEY. Each environment (dev/staging/prod) should have its own key.


Authentication

The SDK authenticates using a project API key passed via the Authorization header as a Bearer token. This is handled automatically — just pass your key to the constructor.

If you’re calling the REST API directly (e.g. from Deno or edge functions), include the header manually:

Authorization: Bearer vr_sk_abc123...

Non-Node.js runtimes

The SDK uses only fetch and standard Web APIs — no Node.js-specific modules. It should work in any runtime that supports fetch, including Deno (npm:versionr).

For edge runtimes like Supabase Edge Functions or Cloudflare Workers, you can also call the REST API directly. See the Deno & Edge Functions guide for examples.


MIT 2026 © Nextra.