Installation
Install the package
npm install versionrInitialize 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
| Option | Type | Default | Description |
|---|---|---|---|
apiKey | string | — | Required. Your project API key. |
baseUrl | string | https://api.versionr.ai | API base URL. Override if self-hosting. |
defaultEnv | string | 'production' | Default environment for all calls. |
timeout | number | 5000 | Request timeout in milliseconds. |
cache | boolean | true | Enable 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