← All @molecule/* packages · App templates
@molecule/api-ai-speech-elevenlabsProvider bond · ai-speech · API (Node) · v1.0.1 · Apache-2.0
ElevenLabs text-to-speech provider for molecule.dev
npm install @molecule/api-ai-speech-elevenlabsnpm · Source on GitHub · Implements @molecule/api-ai-speech
@molecule/api-ai-speech-elevenlabs is a provider bond on the API (Node) side: it implements the ai-speech core interface (@molecule/api-ai-speech) with a concrete vendor or library behind it.
Your code calls the core; you wire this provider once at startup. Swapping vendors later is one line in that wiring, not a rewrite.
Works with: @molecule/api-ai-speech, @molecule/api-secrets
Secrets: ELEVENLABS_API_KEY
Auto-generated, AI-first package reference for the molecule.dev ecosystem. It is written to be read by coding agents as much as by people, and is generated from this package's source — edit
src/index.tsJSDoc, not this file.
ElevenLabs ai-speech provider for molecule.dev.
Text-to-speech via the ElevenLabs API: high-quality single-shot synthesis, chunked streaming synthesis, and voice listing.
provider
npm install @molecule/api-ai-speech-elevenlabs @molecule/api-ai-speech @molecule/api-secrets
ElevenlabsConfigConfiguration for the ElevenLabs speech provider.
interface ElevenlabsConfig {
/** ElevenLabs API key. Defaults to ELEVENLABS_API_KEY env var. */
apiKey?: string
/** Default voice ID. Defaults to 'JBFqnCBsd6RMkjVDRZzb' (George). */
defaultVoiceId?: string
/** Default model for synthesis. Defaults to 'eleven_multilingual_v2'. */
defaultModel?: string
/** Base URL for the ElevenLabs API. Defaults to 'https://api.elevenlabs.io'. */
baseUrl?: string
/** Default output format. Defaults to 'mp3_44100_128'. */
defaultOutputFormat?: string
/** Default voice stability (0.0–1.0). Defaults to 0.5. */
defaultStability?: number
/** Default similarity boost (0.0–1.0). Defaults to 0.75. */
defaultSimilarityBoost?: number
}
ElevenLabsErrorResponseShape of an ElevenLabs API error response.
interface ElevenLabsErrorResponse {
detail?: {
status?: string
message?: string
}
}
ElevenLabsVoiceShape of a voice object in the ElevenLabs API response.
interface ElevenLabsVoice {
voice_id: string
name: string
category?: string
labels?: Record<string, string>
preview_url?: string
available_for_tiers?: string[]
fine_tuning?: Record<string, unknown>
}
ElevenLabsVoicesResponseShape of the ElevenLabs voices list API response.
interface ElevenLabsVoicesResponse {
voices: ElevenLabsVoice[]
}
createProvider(config)Creates an ElevenLabs speech provider instance.
function createProvider(config?: ElevenlabsConfig): AISpeechProvider
config — ElevenLabs-specific configuration (API key, voice, model, base URL).Returns: An AISpeechProvider backed by the ElevenLabs Text-to-Speech API.
aiSpeechElevenlabsSecretDefinitionsSecret definitions required by the ElevenLabs speech bond.
const aiSpeechElevenlabsSecretDefinitions: SecretDefinition[]
providerThe provider implementation.
const provider: AISpeechProvider
Implements @molecule/api-ai-speech interface.
Setup function to register this provider with the core interface:
import { setProvider } from '@molecule/api-ai-speech'
import { provider } from '@molecule/api-ai-speech-elevenlabs'
export function setupAiSpeechElevenlabs(): void {
setProvider(provider)
}
Peer dependencies:
@molecule/api-ai-speech >=1.0.1@molecule/api-secrets ^1.0.1ELEVENLABS_API_KEY (required) — ElevenLabs API key
sk_...@molecule/api-ai-speech
@molecule/api-secrets
TTS-only subset: implements synthesizeSpeech(SpeechParams), synthesizeStream,
and listVoices. It does NOT implement synthesize (the other TTS dialect),
transcribe, or translate — feature-detect per the @molecule/api-ai-speech core
and pair with an STT-capable provider (e.g. @molecule/api-ai-speech-openai) when
the app needs transcription.
Config: ELEVENLABS_API_KEY (required, SERVER-side only); ELEVENLABS_BASE_URL
(optional) overrides the API origin (proxies/gateways), default
https://api.elevenlabs.io.
Integration checklist — drive the real UI (live preview, no mocks), adapt each item to this app's actual screens/flows, and check every box off one by one. A box you can't check is an integration bug to fix — not a skip. The wired provider implements a subset (TTS, STT, or both) — feature-detect and run only the direction(s) it actually exposes:
audio/mpeg) and non-trivial bytes (not a 0-byte file, not a
JSON-encoded blob), and the UI's <audio>/player actually plays it. The
spoken audio reflects the input text you sent.voice/voiceId) or output format (responseFormat/
outputFormat) changes the returned audio (audible voice, Content-Type,
or file extension); an unknown voice/format surfaces a visible error
rather than silently falling back.