Documentation Index
Fetch the complete documentation index at: https://docs.destined.ai/llms.txt
Use this file to discover all available pages before exploring further.
Installation
npm install @destined-ai/voice
Quick Start
import { SDK } from "@destined-ai/voice";
const client = new SDK({
bearerToken: process.env.DESTINED_API_KEY,
});
// List speakers
const speakers = await client.speakers.listSpeakersV1SpeakersGet({
gender: "Female",
limit: 10,
});
// Generate speech
const audio = await client.ttsGeneration.synthesizeSpeechV1TtsSynthesizePost({
speakerId: speakers[0].id,
text: "Hello from Destined Voice!",
});
console.log(audio.audioUrl);
Available Namespaces
| Namespace | Description |
|---|
client.health | API health checks |
client.speakers | Browse and filter speakers |
client.ttsGeneration | Generate TTS audio |
client.jobs | Track batch job progress |
client.sttTesting | STT provider testing |
client.datasets | CSV dataset import |
client.users | User profile and usage |
client.billing | Subscription management |
Configuration
import { SDK } from "@destined-ai/voice";
const client = new SDK({
// Required: Your API key
bearerToken: process.env.DESTINED_API_KEY,
// Optional: Override base URL (default: https://api.destined.ai)
serverURL: "https://api.destined.ai",
// Optional: Custom fetch implementation
httpClient: customFetch,
});
Error Handling
import { SDK } from "@destined-ai/voice";
import { SDKError } from "@destined-ai/voice/models/errors";
const client = new SDK({
bearerToken: process.env.DESTINED_API_KEY,
});
try {
const result = await client.ttsGeneration.synthesizeSpeechV1TtsSynthesizePost({
speakerId: "invalid-id",
text: "Hello",
});
} catch (error) {
if (error instanceof SDKError) {
console.log("Status:", error.statusCode);
console.log("Message:", error.message);
console.log("Body:", error.body);
}
}
TypeScript Types
All request/response types are exported:
import type {
SpeakerResponse,
SynthesizeRequest,
JobStatus,
} from "@destined-ai/voice/models";
const request: SynthesizeRequest = {
speakerId: "abc123",
text: "Hello world",
};
Next.js Usage
// app/api/synthesize/route.ts
import { SDK } from "@destined-ai/voice";
import { NextResponse } from "next/server";
const client = new SDK({
bearerToken: process.env.DESTINED_API_KEY!,
});
export async function POST(request: Request) {
const { speakerId, text } = await request.json();
const result = await client.ttsGeneration.synthesizeSpeechV1TtsSynthesizePost({
speakerId,
text,
});
return NextResponse.json(result);
}
React Hook Example
import { useState, useCallback } from "react";
import { SDK } from "@destined-ai/voice";
const client = new SDK({
bearerToken: process.env.NEXT_PUBLIC_DESTINED_API_KEY!,
});
export function useSynthesis() {
const [loading, setLoading] = useState(false);
const [error, setError] = useState<Error | null>(null);
const synthesize = useCallback(async (speakerId: string, text: string) => {
setLoading(true);
setError(null);
try {
const result = await client.ttsGeneration.synthesizeSpeechV1TtsSynthesizePost({
speakerId,
text,
});
return result;
} catch (e) {
setError(e as Error);
throw e;
} finally {
setLoading(false);
}
}, []);
return { synthesize, loading, error };
}