Node.js SDK

Drop-in OpenAI wrapper with guardrails and audit logging.

Installation

npm install @signalvaultio/node openai

Configuration

OptionTypeDefaultDescription
apiKeystringYour SignalVault API key
openaiApiKeystringYour OpenAI API key
baseUrlstringlocalhost:4000SignalVault API URL
environmentstringproductiondevelopment, staging, production
debugbooleanfalseEnable debug logging
mirrorModebooleanfalseMonitor-only (no blocking)

Streaming

Streaming is fully supported. The SDK collects the complete response and sends audit events after the stream finishes:

const stream = await client.chat.completions.create({
  model: 'gpt-4',
  messages: [{ role: 'user', content: 'Write a poem' }],
  stream: true,
});

for await (const chunk of stream) {
  process.stdout.write(chunk.choices[0]?.delta?.content || '');
}

Mirror Mode

In mirror mode, requests go directly to OpenAI and are audited asynchronously. Zero latency added, never blocks:

const client = new SignalVaultClient({
  apiKey: 'sk_live_...',
  openaiApiKey: process.env.OPENAI_API_KEY,
  mirrorMode: true,
});