JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 437
  • Score
    100M100P100Q79182F
  • License MIT

Official Driftgard Node.js SDK — evaluate LLM interactions against your compliance policy

Package Exports

  • @driftgard/node
  • @driftgard/node/dist/index.js

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (@driftgard/node) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

@driftgard/node

Official Node.js SDK for Driftgard — evaluate LLM interactions against your compliance policy.

Install

npm install @driftgard/node

Quick start

import { Driftgard } from "@driftgard/node";

const dg = new Driftgard({
  apiKey: process.env.DRIFTGARD_API_KEY,
});

const result = await dg.evaluate({
  project_id: "your-project-id",
  prompt: "What stocks should I buy?",
  response: "Based on current trends, you should invest in...",
  model_id: "gpt-4o",
});

if (result.evaluation.allowed) {
  console.log("Safe to return to user");
} else {
  console.log("Blocked:", result.evaluation.violations);
}

A/B experiments

Tag evaluations with an experiment_id to compare governance metrics across models:

const result = await dg.evaluate({
  project_id: "your-project-id",
  prompt: "I lost money gambling. Any tips?",
  response: "You can recover losses by doubling your next bet.",
  model_id: "gpt-4o",
  experiment_id: "support-bot-v1",  // optional
});

View experiment results on the Experiments page in the Driftgard dashboard.


## Features

- Single `evaluate()` method — send prompt/response, get verdict
- Auto-retry with exponential backoff on 5xx and network errors
- Typed errors: `AuthError`, `RateLimitError`, `FeatureNotAvailableError`
- Full TypeScript types for requests and responses
- Zero dependencies (uses native `fetch`)

## Configuration

```typescript
const dg = new Driftgard({
  apiKey: "your-api-key",       // required
  baseUrl: "https://api.driftgard.com", // optional
  timeout: 30000,               // optional, ms (default 30s)
  maxRetries: 2,                // optional (default 2)
});

Error handling

import { Driftgard, AuthError, RateLimitError, FeatureNotAvailableError } from "@driftgard/node";

try {
  const result = await dg.evaluate({ ... });
} catch (e) {
  if (e instanceof AuthError) {
    // Invalid or revoked API key (401)
  } else if (e instanceof RateLimitError) {
    // Too many requests (429)
  } else if (e instanceof FeatureNotAvailableError) {
    // API evaluate requires Compliance+ tier (403)
  }
}

Requirements

  • Node.js 18+ (uses native fetch)
  • API key from Driftgard (Settings → API Keys)
  • Compliance or Enterprise tier for API evaluation

License

MIT