Skip to main content

JavaScript SDK

The official Visent JavaScript SDK provides seamless integration with Visent APIs for Node.js applications and browser environments. Access Telemetry metrics, Atlas pricing data, and Forge benchmarking capabilities with TypeScript support and modern async/await patterns. Supports both CommonJS and ES modules with comprehensive error handling and retry logic.

Installation

# Using npm
npm install @visent/sdk

# Using yarn
yarn add @visent/sdk

# Using pnpm
pnpm add @visent/sdk

Quick Start

Basic Setup

const { VisentClient } = require('@visent/sdk');

// Initialize client
const client = new VisentClient({
  apiKey: process.env.VISENT_API_KEY,
  // Optional: specify environment
  environment: 'production' // or 'staging'
});

// TypeScript/ES modules
import { VisentClient } from '@visent/sdk';

const client = new VisentClient({
  apiKey: process.env.VISENT_API_KEY
});

Telemetry API

// Get current GPU metrics
const metrics = await client.telemetry.getMetrics({
  node: 'gpu-worker-1',
  gpu: 0
});

console.log('GPU Utilization:', metrics.utilization);
console.log('Memory Usage:', metrics.memory_used);

// Stream real-time metrics
const stream = client.telemetry.streamMetrics({
  nodes: ['gpu-worker-1', 'gpu-worker-2']
});

stream.on('data', (metric) => {
  console.log('New metric:', metric);
});

stream.on('error', (error) => {
  console.error('Stream error:', error);
});

Atlas API

// Get current pricing
const pricing = await client.atlas.getCurrentPricing({
  gpu: 'h100',
  provider: 'aws',
  region: 'us-east-1'
});

console.log('Price per hour:', pricing.price_per_hour);

// Get cost optimization recommendations
const recommendations = await client.atlas.getOptimizationRecommendations({
  workload: 'ml-training',
  budget: 10000,
  duration: '30d'
});

Forge API

// Start a benchmark
const benchmark = await client.forge.startBenchmark({
  type: 'ml-training',
  gpu: 'h100',
  config: {
    model: 'resnet50',
    batch_size: 32,
    iterations: 100
  }
});

// Monitor benchmark progress
const job = await client.forge.waitForCompletion(benchmark.job_id);
console.log('Benchmark completed:', job.results);

Configuration

Coming soon - advanced configuration options and client settings.

Error Handling

Coming soon - comprehensive error handling patterns and best practices.

TypeScript Support

Coming soon - TypeScript types and interfaces documentation.

Browser Support

Coming soon - using the SDK in browser environments with bundlers.

Testing

Coming soon - testing applications that use the Visent SDK.

Examples

Coming soon - practical examples and integration patterns.

Next Steps