TypeScript / JavaScript SDK
The official SDK is @verna/verna-promptlab-sdk — a typed client for Node and modern runtimes that calls your prompts as versioned, model-agnostic endpoints.
Install
The SDK is distributed through the Verna GitLab package registry. Point the @verna scope at the registry, then install:
npm config set @verna:registry https://gitlab.com/api/v4/packages/npm/
npm install @verna/verna-promptlab-sdk
The
@vernascope only affects packages under@verna/…; the rest of your dependencies still resolve from your default registry.
Create a client
import { PromptLabRouterClient } from '@verna/verna-promptlab-sdk';
const client = new PromptLabRouterClient({
routerUrl: 'https://router.promptlab.vernalabs.net',
projectId: 'YOUR_PROJECT_ID',
apiKey: process.env.VERNA_API_KEY, // plp_xxx_xxx
});
Constructor options
| Option | Required | Notes |
|---|---|---|
routerUrl | yes | e.g. https://router.promptlab.vernalabs.net |
projectId | yes | your project id |
apiKey | one of | project key (plp_…) — sent as x-api-key |
internalServiceKey | one of | for trusted internal services instead of apiKey |
workspaceId | no | multi-workspace scoping |
environment | no | e.g. prod, staging |
timeoutMs | no | request timeout (default 30000) |
defaultHeaders | no | extra headers on every request |
fetch | no | custom fetch implementation |
Execute a prompt
const res = await client.executePrompt('summarize-ticket', {
inputs: { ticket: 'User cannot log in after a password reset.' },
// version: '3', // pin a specific version (defaults to active)
// options: { temperature: 0.2 },
});
const text = res.outputs[0]?.text;
console.log(text, res.provider.model, res.cost);
executePrompt(promptName, request?) returns a UnifiedExecutionResponse — the same envelope for text and media, sync and async.
Request fields (all optional except your inputs):
inputs— values for the prompt’s{{variables}}version— pin a prompt version (defaults to the active one)options— per-call overrides (temperature,maxTokens,seed,executionMode, …)context—{ agentId?, metadata? }trace—{ correlationId? }
Other methods
await client.listPrompts(); // active prompts in the project
await client.getPrompt('summarize-ticket'); // one prompt's contract (+ version, template)
await client.getJob(jobId); // poll an async (media) job
Async / media jobs
Media generation runs asynchronously. When res.status is queued/running, poll with getJob:
let job = await client.executePrompt('render-hero-image', { inputs: { brief } });
while (job.status !== 'succeeded' && job.status !== 'failed') {
await new Promise((r) => setTimeout(r, 2000));
job = await client.getJob(job.async!.jobId);
}
console.log(job.outputs[0]?.url);
Types
The package ships full TypeScript types (PromptLabClientOptions, ExecutePromptRequest, UnifiedExecutionResponse, and the outputs[] union). Import them alongside the client for end-to-end type safety.
No Python SDK is published yet. From Python (or any language), call the HTTP API directly — it’s the same endpoints this SDK wraps.