@vouch-ai/sdk package wires OpenLLMetry auto-instrumentation into every LLM client running in your Node.js process — OpenAI, Anthropic, LangChain, Bedrock, LlamaIndex, and more — and ships the resulting OpenTelemetry spans to your Trident project at app.usetrident.dev. PII redaction runs entirely inside your process before any trace data leaves, so emails, API keys, credit card numbers, and other sensitive values are scrubbed at the edge, never in transit.
Requirements
- Node.js 20 or later (the SDK is published as native ESM)
- npm, yarn, or pnpm
Install
Set your environment variables
Open your project’s.env file (or your deployment platform’s secrets manager) and add the keys from your project’s Settings → API Keys page at app.usetrident.dev:
.env
VOUCH_PROJECT_PUBLIC_KEY / VOUCH_PROJECT_SECRET_KEY names for backwards compatibility.
Initialize Trident
Calltrident.init() once, at the very top of your application entry point, before you import or instantiate any LLM client. Every LLM call made after init() is automatically traced.
projectPk and projectSk are omitted, init() reads them from TRIDENT_PROJECT_PUBLIC_KEY / TRIDENT_PROJECT_SECRET_KEY automatically, so the call can be reduced to a bare trident.init() if you prefer to keep credentials only in the environment.
All options
| Option | Type | Default | Description |
|---|---|---|---|
projectPk | string | env | Project public key. |
projectSk | string | env | Project secret key. |
agentId | string | env | Logical agent identifier shown in the dashboard. Reads TRIDENT_AGENT_ID. |
agentUrl | string | env / sniffed | Public HTTP endpoint where the agent receives prompts, used by the Red Team page. Reads TRIDENT_AGENT_URL, then VOUCH_AGENT_URL. If not set the SDK sniffs the URL from platform env vars (Vercel, Fly, Render, Railway, Heroku, Koyeb, Cloudflare Workers, AWS App Runner) and falls back to observing http.Server.listen. |
agentPath | string | / | Path the agent’s handler is mounted at (e.g. /api/chat). Reads TRIDENT_AGENT_PATH. Used when assembling a URL from a sniffed host. |
sniffAgentUrl | boolean | true | Set false to disable the http.Server.prototype.listen hook entirely. |
endpoint | string | https://app.tryvouch.ai | Override the Trident host. Reads TRIDENT_ENDPOINT. |
appName | string | agentId | OTel resource app name. Falls back to "vouch-app". |
disableBatch | boolean | false | Emit each span immediately instead of batching. Useful for short-lived scripts. |
redactPII | boolean | { rules?: PiiRule[] } | true | Edge PII redaction. true uses the built-in rule set; pass { rules } for custom rules; false disables. |
traceloopOptions | Record<string, unknown> | — | Extra options forwarded verbatim to the underlying Traceloop.init() call. |
Full working example
The snippet below starts Trident tracing, then makes a standard OpenAI chat completion. The completion call is traced automatically — no wrapping or middleware required.Zero-code option (no source changes)
If you want Trident traces without touching your source code, use the@vouch-ai/sdk/register module with Node’s --import flag. The module reads your credentials from environment variables and calls init() automatically before your application starts.
- Command line
- NODE_OPTIONS (Next.js / Vercel)
- package.json scripts
The register module is a silent no-op if
TRIDENT_PROJECT_PUBLIC_KEY or TRIDENT_PROJECT_SECRET_KEY are not set — it never throws and never breaks your app. In non-production environments it prints a warning to help you catch misconfigurations early.Supported LLM frameworks
The SDK auto-instruments all of the following when they are loaded in the same process:OpenAI
Anthropic
LangChain
CrewAI
LlamaIndex
Amazon Bedrock
Google VertexAI
Cohere
MCP (Model Context Protocol)
OpenAI Agents SDK
init() runs.
PII redaction is on by default. Before any span attribute leaves your process, the SDK scans it for and replaces the following patterns with
[REDACTED_<TYPE>] tokens:- EMAIL — email addresses
- CREDIT_CARD — card numbers (Luhn-validated to avoid false positives)
- SSN — US Social Security Numbers (
XXX-XX-XXXX) - AWS_KEY — AWS access key IDs (
AKIA…,ASIA…) - JWT — JSON Web Tokens
- API_KEY — API keys (
sk-…,sk-ant-…) - IBAN — International Bank Account Numbers
- IP — IPv4 addresses
- PHONE — phone numbers
redactPII: false to init() to disable, or redactPII: { rules: [...] } to supply your own rule set.Next steps
TypeScript SDK API Reference
Explore the full API:
trident.init(), trident.scan(), trident.selfReport(), and all configuration options.