Speko Docs

Speech

Synthesize audio through generateSpeech with routed TTS providers.

Pass speko.speech(...) to the AI SDK's generateSpeech.

import { speko } from '@spekoai/ai-sdk-provider';
import { generateSpeech } from 'ai';

const { audio } = await generateSpeech({
  model: speko.speech('auto'),
  text: 'Welcome to Speko.',
  voice: 'QtY3JBOUKEB5xzrRfOKc',
  providerOptions: {
    speko: { language: 'en', optimizeFor: 'latency' },
  },
});

voice is optional and provider-specific. Leave it out and the router picks a voice for the resolved language.

Output format

audio.uint8Array returns WAV by default. Request raw signed 16-bit little-endian mono PCM instead:

const { audio } = await generateSpeech({
  model: speko.speech('auto'),
  text: 'Welcome to Speko.',
  providerOptions: {
    speko: { outputFormat: 'pcm' },
  },
});

The sample rate of the routed provider is reported in providerMetadata.speko.sampleRate.

Pinning a provider or model

The model id selects a routing strategy rather than a single model:

speko.speech('auto-quality');                        // bias toward quality
speko.speech('elevenlabs/eleven_multilingual_v2');   // pin provider and model

See Routing options for the full id list and every providerOptions.speko field.

On this page