Node.js SDK
Drop-in OpenAI wrapper with guardrails and audit logging.
Installation
npm install @signalvaultio/node openai
Configuration
| Option | Type | Default | Description |
|---|---|---|---|
| apiKey | string | — | Your SignalVault API key |
| openaiApiKey | string | — | Your OpenAI API key |
| baseUrl | string | localhost:4000 | SignalVault API URL |
| environment | string | production | development, staging, production |
| debug | boolean | false | Enable debug logging |
| mirrorMode | boolean | false | Monitor-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,
});