License setup — Node
You imported @dvai-bridge/core in a Node script, Next.js server route, serverless function, or Electron main process. Here's the path from zero to a license-enforced production build.
TL;DR
Place dvai-license.jwt at your project root — next to package.json. The SDK reads it on initialize(). Production throws LicenseRequiredError if the file is missing or invalid. NODE_ENV=development and NODE_ENV=test skip the check.
Where the file goes
Priority order — first match wins:
- Inline JWT —
new DVAI({ licenseToken: "..." }) - Explicit path —
new DVAI({ licenseKeyPath: "/etc/dvai/license.jwt" }) DVAI_LICENSE_PATHenvironment variableDVAI_LICENSE_TOKENenvironment variable — inline JWT- Auto-discovery —
dvai-license.jwtinprocess.cwd(), then one level up — handy for monorepos where youcd packages/myappandnode ./dist/server.js
For containerised deployments, point DVAI_LICENSE_PATH at a mounted secret — a Kubernetes secret, a Docker --secret. The SDK reads the file once at startup. Never touches it again.
Code: with vs. without
Default discovery — Node finds ./dvai-license.jwt:
import { DVAI } from "@dvai-bridge/core";
const dvai = new DVAI({ backend: "transformers" });
await dvai.initialize();
console.log(dvai.licenseStatus); // { kind: "commercial", licensee: ... }
console.log(dvai.baseUrl); // http://127.0.0.1:38883/v1Inline JWT — CI / serverless friendly:
const dvai = new DVAI({
backend: "transformers",
licenseToken: process.env.DVAI_LICENSE_JWT,
});
await dvai.initialize();Explicit path:
const dvai = new DVAI({
backend: "transformers",
licenseKeyPath: "/run/secrets/dvai-license.jwt",
});Via environment variable — no code changes:
DVAI_LICENSE_PATH=/run/secrets/dvai-license.jwt node ./server.js
# or
DVAI_LICENSE_TOKEN=$(cat license.jwt) node ./server.jsWhat happens without a license
In production, initialize() throws LicenseRequiredError before any backend loads. The error message tells you exactly which check failed.
import { DVAI, LicenseRequiredError } from "@dvai-bridge/core";
try {
await dvai.initialize();
} catch (err) {
if (err instanceof LicenseRequiredError) {
console.error(err.message);
console.error("status:", err.status.kind); // "free-prod" | "free-expired"
process.exit(1);
}
throw err;
}A typical message looks like:
DVAI-Bridge Commercial License Required
=======================================
no license token found; checked config.licenseToken,
config.licenseKeyPath, DVAI_LICENSE_PATH env, DVAI_LICENSE_TOKEN env,
and platform-default paths
This SDK is licensed under BSL 1.1 and requires a valid commercial
or trial license to run in production / release builds.
... (resolution steps)Testing locally without a license
Three ways:
# 1. NODE_ENV=test or NODE_ENV=development — most natural for tests.
NODE_ENV=test node ./tests/run.js
# 2. Explicit override — for ad-hoc local runs.
DVAI_FORCE_DEV=1 node ./server.js
# 3. Use a `dvai-license.jwt` file (real or sample from the
# generate-keypair script's output).To rehearse production behaviour locally, set DVAI_FORCE_PROD=1. It overrides every dev-mode signal. The SDK throws if the license is missing.
Audience binding for servers
Server-side Node has no browser hostname. Tell the SDK which aud claim to match:
DVAI_AUDIENCE=api.acme.com node ./server.jsIf DVAI_AUDIENCE is unset, the SDK accepts any license whose aud claim contains "*" — the any-host wildcard. It refuses ones bound to specific domains. Most commercial licenses ship "*" and this works out of the box. Bind explicitly with DVAI_AUDIENCE for stricter checks.
When validation fails
Common Node-specific failures:
| Error reason fragment | What's wrong | Fix |
|---|---|---|
no license token found | File missing at all 5 discovery paths | Drop one in, or set DVAI_LICENSE_PATH |
does not authorise platform "node" | License doesn't include "node" in platforms | Re-issue covering node |
audience entries ... do not match | DVAI_AUDIENCE doesn't match any aud entry | Set DVAI_AUDIENCE or use a * license |
See also
- License setup index
- Pre-init inspection — run
LicenseValidatorstandalone in a script / CLI / health endpoint without booting the backend. - Web — browser-side flow.
- Reference: DVAIConfig.licenseKeyPath / licenseToken.
