TypeScript SDK

Call the Trust Engine from any JavaScript runtime — Node, Next.js, Deno, or the edge.

REST-first

From TypeScript, call the REST API directly — no native dependency required. Always call it from server-side code (route handlers, server actions) so your vx-live- key never reaches the browser.

A thin typed client

TypeScript
type Verdict = "ALLOW" | "WARN" | "REVIEW" | "BLOCK";

interface EvalResponse {
  data: {
    request_id: string;
    final_score: { value: number; confidence: number; risk_level: string };
    pillar_results: Record<string, { score: { value: number }; flags: string[] }>;
    execution_time_ms: number;
  };
}

export async function evaluate(prompt: string, response: string, model = "gpt-4o") {
  const res = await fetch("https://api.veldrixai.ca/trust/evaluate", {
    method: "POST",
    headers: {
      Authorization: "Bearer " + process.env.VELDRIX_API_KEY,
      "Content-Type": "application/json",
    },
    body: JSON.stringify({ prompt, response, model }),
  });
  if (!res.ok) throw new Error("VeldrixAI " + res.status);
  return (await res.json()) as EvalResponse;
}

Result types

Over REST, final_score.value is on a 0–100 scale and risk_level mirrors the verdict band. Normalize to 0–1 (value / 100) if you want parity with the Python SDK's overall.

A first-class TypeScript SDK with the guard/middleware ergonomics of the Python package is on the roadmap. Until then this pattern is fully supported and production-ready.
Was this page helpful?