Programmable AI Infrastructure Node.js SDK
npm install @voniai/nodejsThe official Node.js SDK for the Voniai programmable AI infrastructure.
``bash`
npm install @voniai/nodejs
`javascript
const { Voni } = require('@voniai/nodejs');
// Initialize the client (automatically loads VONI_API_KEY from env)
const voni = new Voni({});
async function main() {
// Send a message to your co-pilot
const response = await voni.chat.sendMessage('your_project_id', {
message: 'How do I integrate Voni?',
sessionId: 'user_123'
});
console.log(AI Response: ${response.message});
}
main();
`
- TypeScript Support: Full type definitions included.
- Robust Security: Automatic HMAC-SHA256 request signing.
- Environment Support: Automatically loads VONI_API_KEY from environment variables.
- Headless Chat: Build custom AI interfaces.
- Management API: Control projects and webhooks via code.
The SDK handles HMAC signature generation automatically. You can provide your API Key during initialization or set the VONI_API_KEY environment variable.
`javascript
// Option 1: Load from environment (Recommended)
const voni = new Voni({});
// Option 2: Explicitly provide key
const voni = new Voni({ apiKey: '...' });
`
`javascript
const { VoniAuthError, VoniApiError } = require('@voniai/nodejs');
try {
const projects = await voni.projects.list();
} catch (error) {
if (error instanceof VoniAuthError) {
console.error('Authentication failed');
} else if (error instanceof VoniApiError) {
console.error(API Error: ${error.statusCode});``
}
}
MIT