SDK
@hypervideo-dev/sdk is the official TypeScript SDK for the Hypervideo API. Works in Node.js and browser environments.
Installation
bash
npm install @hypervideo-dev/sdkSetup
typescript
import { Hypervideo } from '@hypervideo-dev/sdk';
const client = new Hypervideo({ apiKey: 'hc_...' });Sync Processing
typescript
const result = await client.video.removeBackground({ file: videoFile, // File or Buffer format: 'webp', // Single format quality: 40, // WebP/APNG quality});
console.log(result.url); // base64 data URLconsole.log(result.format); // "webp"console.log(result.size); // bytesconsole.log(result.processingTime); // msMultiple Formats
typescript
const result = await client.video.removeBackground({ file: videoFile, formats: ['webp', 'stacked-alpha'],});
for (const output of result.outputs) { console.log(output.format, output.url, output.size);}Async Jobs
For longer videos, use the jobs API to avoid timeouts:
typescript
// Submit job (returns immediately)const { jobId } = await client.jobs.submit({ file: videoFile, formats: ['webm', 'stacked-alpha'],});
// Poll with progress callbackconst job = await client.jobs.poll(jobId, { onProgress: (j) => { console.log(`${j.progress}% - ${j.stage}`); },});
// Access resultsconsole.log(job.result.outputUrl);console.log(job.result.outputs);From URL
typescript
const result = await client.video.removeBackground({ url: 'https://example.com/video.mp4', format: 'webp',});Image Processing
typescript
// Remove image backgroundconst image = await client.image.removeBackground({ file: imageFile, tolerance: 30,});
// Detect background colorconst color = await client.image.detectBackgroundColor({ file: imageFile,});console.log(color.hex); // "#E92FBC"Configuration
typescript
const client = new Hypervideo({ apiKey: 'hc_...', baseUrl: 'https://api.hypervideo.dev', // default});