SDKs
JavaScript/TypeScript SDK
Complete guide to the 60db JavaScript/TypeScript SDK
Documentation Index
Fetch the complete documentation index at: /llms.txt
Use this file to discover all available pages before exploring further.
Complete guide to the 60db JavaScript/TypeScript SDK
npm install 60db
import { SixtyDBClient } from "60db";
// Simple initialization
const client = new SixtyDBClient("your-api-key");
const audio = await client.textToSpeech({
text: 'Hello, world!',
voice_id: 'default-voice',
enhance: true,
speed: 1.0,
language:"en-us"
});
### Get all voices
const voices = await client.getVoices();
### Get all lanuages
const lanuages = await client.getLanguages();
### audio is an ArrayBuffer containing the audio data
const file = document.querySelector('input[type="file"]').files[0];
const result = await client.speechToText(file, {
language: "en",
});
console.log(result.text);
const languages = await client.getLanguages();
console.log(languages);
const voices = await client.getVoices();
voices.forEach((voice) => {
console.log(`${voice.name} (${voice.id})`);
});
const voice = await client.getVoice("voice-id");
console.log(voice);
const files = [file1, file2, file3]; // File objects
const newVoice = await client.createVoice({
name: "My Custom Voice",
files: files,
description: "A custom voice for my brand",
});
console.log("Created voice:", newVoice.id);
await client.updateVoice("voice-id", {
name: "Updated Voice Name",
description: "Updated description",
});
await client.deleteVoice("voice-id");
const user = await client.signUp({
email: "user@example.com",
password: "secure-password",
name: "John Doe",
});
const session = await client.signIn({
email: "user@example.com",
password: "secure-password",
});
console.log("Token:", session.token);
const profile = await client.getProfile();
console.log(profile);
await client.updateProfile({
name: "Jane Doe",
company: "Acme Inc",
});
const workspaces = await client.getWorkspaces();
const workspace = await client.createWorkspace({
name: "My Workspace",
description: "Team workspace",
});
const plans = await client.getPlans();
plans.forEach((plan) => {
console.log(`${plan.name}: $${plan.price}/month`);
});
const currentPlan = await client.getCurrentPlan();
console.log("Current plan:", currentPlan.name);
await client.subscribe("plan-id");
const usage = await client.getUsage();
console.log("Characters used:", usage.characters);
console.log("API calls:", usage.api_calls);
const apiKeys = await client.getApiKeys();
const newKey = await client.createApiKey("Production Key");
console.log("New API key:", newKey.key);
await client.deleteApiKey("key-id");
const webhooks = await client.getWebhooks();
const webhook = await client.createWebhook({
url: "https://example.com/webhook",
events: ["tts.completed", "stt.completed"],
});
await client.deleteWebhook("webhook-id");
try {
const audio = await client.textToSpeech({
text: "Hello, world!",
voice_id: "invalid-voice",
});
} catch (error) {
if (error.response) {
// API error
console.error("API Error:", error.response.status);
console.error("Message:", error.response.data.message);
} else {
// Network or other error
console.error("Error:", error.message);
}
}
import { SixtyDBClient, SixtyDBConfig, TTSResponse } from "60db";