Skip to content

GETTING STARTED

Quick start

Resolve an exact Behavior revision and attach the resulting trace.

Last updated

Install

Use Node 20+ and pnpm. The SDK defaults to fail-open for runtime resolution; choose fail-closed for policy-critical paths.

pnpm add @vira-behavior/sdk

Resolve

Keep the traceId and exact revision returned by resolve. Do not calculate or substitute a revision in the client.

import { ViraClient } from "@vira-behavior/sdk";
const projectId = "<project-uuid>";
const applicationId = "<application-uuid>";
const vira = new ViraClient({ baseUrl: process.env.VIRA_API_URL!, apiKey: process.env.VIRA_API_KEY!, failureMode: "open" });
const behavior = await vira.resolve({ projectId, applicationId, environment:"production", behaviorPoint:"support.decision", subjectId:user.id, provider:"openai", signals:{ issue_type:"delivery", same_issue_count:3 } });

Trace

Persist the model output against the resolve-issued identity. Idempotency keys must be stable across retries.

if (behavior) await vira.trace({ id:behavior.traceId, projectId, applicationId, behaviorPoint:"support.decision", profileId:behavior.revision.profileId, revision:behavior.revision.revision, signals, content:{ output } }, requestId);