Creates a new OpenAITextToSpeechProvider.
Provider configuration including API key and optional defaults.
const provider = new OpenAITextToSpeechProvider({
apiKey: 'sk-xxxx',
voice: 'shimmer',
});
Synthesizes speech from text using the OpenAI TTS API.
The text to convert to audio. Maximum 4096 characters.
Optional synthesis settings including voice, model, output format, and speed (0.25–4.0 range).
A promise resolving to the audio buffer and metadata.
When the OpenAI API returns a non-2xx status code. Common causes: invalid API key (401), rate limit (429), text too long (400).
const result = await provider.synthesize('Hello world', {
voice: 'alloy',
speed: 1.2,
outputFormat: 'opus',
});
Returns the static list of available OpenAI TTS voices.
Unlike other providers (ElevenLabs, Azure) that require an API call to list voices, OpenAI's voice catalog is fixed and hardcoded. This method returns a shallow copy to prevent external mutation.
A promise resolving to the 6 built-in OpenAI voice options.
const voices = await provider.listAvailableVoices();
const defaultVoice = voices.find(v => v.isDefault); // 'nova'
Readonly idUnique provider identifier used for registration and resolution.
Readonly displayHuman-readable display name for UI and logging.
Readonly supportsStreaming is supported — the OpenAI API streams audio bytes as they are generated, enabling low-latency playback pipelines.
Text-to-speech provider that uses the OpenAI TTS API.
API Contract
POST {baseUrl}/audio/speechAuthorization: Bearer <apiKey>application/json{ model, voice, input, response_format, speed }Models
tts-1— Optimized for real-time, lower latency, slightly lower qualitytts-1-hd— Higher quality at the cost of additional latencyVoice Listing
OpenAI's voice catalog is static (6 voices), so
listAvailableVoices()returns a hardcoded list fromOPENAI_VOICESwithout making an API call.See
Example