VB-OS Node.js SDK Authentication
Constructor
Section titled “Constructor”import { VBOSClient } from '@vb-os/sdk';
const client = new VBOSClient({ apiKey: 'vbos_key_...',});The apiKey parameter is required. All other parameters are optional.
Options
Section titled “Options”| Parameter | Type | Default | Description |
|---|---|---|---|
apiKey |
string |
(required) | API key for authentication |
baseUrl |
string |
https://api.vb-os.org |
API base URL |
timeout |
number |
30 |
Request timeout in seconds |
maxRetries |
number |
3 |
Maximum retry attempts for failed requests |
randomFn |
() => number |
Math.random |
Random function for jitter (useful in tests) |
Full Example
Section titled “Full Example”const client = new VBOSClient({ apiKey: process.env.VBOS_API_KEY, baseUrl: 'https://api.vb-os.org', timeout: 60, maxRetries: 5,});API Key from Environment
Section titled “API Key from Environment”Store your API key in an environment variable rather than hardcoding it:
const client = new VBOSClient({ apiKey: process.env.VBOS_API_KEY,});Deterministic Testing
Section titled “Deterministic Testing”Pass a custom randomFn to make retry jitter deterministic in tests:
const client = new VBOSClient({ apiKey: 'test-key', randomFn: () => 0.5,});Request Headers
Section titled “Request Headers”The SDK automatically sets the following headers on every request:
Authorization: Bearer <apiKey>Content-Type: application/jsonUser-Agent: @vb-os/sdk/0.1.0
