Skip to content

Quickstart

1. Initialize the client

import { VyonicaClient } from 'vyonica';
const client = new VyonicaClient({
apiKey: 'nvsk_your_api_key_here',
baseUrl: 'http://localhost:8000', // default
});

The clone() method handles everything: submitting the job, polling for completion, and returning the audio buffer.

import { VyonicaClient } from 'vyonica';
import fs from 'fs';
const client = new VyonicaClient({ apiKey: 'nvsk_...' });
const audioBuffer = await client.clone(
fs.readFileSync('reference.wav'),
{ text: 'Hello world', language: 'en' }
);
fs.writeFileSync('output.wav', audioBuffer);

Custom poll options

const audioBuffer = await client.clone(
fs.readFileSync('reference.wav'),
{
text: 'Hello world',
language: 'en',
temperature: 0.7,
exaggeration: 0.5,
},
{
intervalMs: 3000, // poll every 3 seconds (default: 2000)
timeoutMs: 120_000, // give up after 2 minutes (default: 300_000)
}
);

If the job doesn’t finish within timeoutMs, the SDK throws a JobTimeoutError. See Error handling for the full list.

Next steps