/** * ElevenLabs provider — premium TTS + STT (#B9). * * Implements `TextToSpeechAdapter` + `SpeechToTextAdapter` only — ElevenLabs * has no chat-completions surface, so `create()` throws. Apps reach this * provider through `AudioGenerator.of(...).model('elevenlabs/').generate()` * and `Transcription.of(...).model('elevenlabs/scribe_v1').transcribe()`. * * Wire-protocol via raw `fetch` (no SDK peer dep), matching the Jina / * Cohere shape. ElevenLabs's REST API is small enough that pulling in * `@elevenlabs/elevenlabs-js` (or any SDK) would add weight without much * leverage. * * @example Config-driven (recommended) * ```ts * // config/ai.ts * export default { * default: 'openai/gpt-4o', * providers: { * openai: { driver: 'openai', apiKey: env('OPENAI_API_KEY')! }, * elevenlabs: { driver: 'elevenlabs', apiKey: env('ELEVENLABS_API_KEY')! }, * }, * } * * // somewhere in app code * await AudioGenerator * .of('Hello world') * .model('elevenlabs/21m00Tcm4TlvDq8ikWAM') // voice_id (Rachel) * .generate() * ``` * * @example Failover from OpenAI TTS to ElevenLabs * ```ts * await AudioGenerator * .of('Hello') * .model('openai/tts-1-hd') * .failover('elevenlabs/21m00Tcm4TlvDq8ikWAM') * .generate() * ``` * * # Model strings * * **TTS:** the model string after `elevenlabs/` is the **voice id** * (e.g. `21m00Tcm4TlvDq8ikWAM` for Rachel). The actual TTS model * (`eleven_multilingual_v2`, `eleven_turbo_v2_5`, ...) defaults to * {@link DEFAULT_TTS_MODEL_ID}; override via `ElevenLabsConfig.defaultTtsModelId`. * Voice ids are the discriminator most apps want to vary per-call — the * underlying TTS model is usually stable per deployment. * * **STT:** the model string is the actual model id (`scribe_v1` is the * only model today). * * # Format mapping (TTS) * * `TextToSpeechOptions.format` maps to ElevenLabs's `output_format`: * * | Our format | ElevenLabs | * |---|---| * | `mp3` (default) | `mp3_44100_128` | * | `opus` | `opus_48000_128` | * | `wav` / `aac` / `flac` | not supported by ElevenLabs — throws clearly | * * # Speed knob (TTS) * * `TextToSpeechOptions.speed` is **ignored** by this adapter — ElevenLabs * doesn't expose a top-level speed multiplier on the TTS endpoint * (timing is steered via `voice_settings.stability` etc., out of scope * for v1). OpenAI's TTS supports speed natively; failover from OpenAI * to ElevenLabs will produce audio at default speed. */ import type { ProviderFactory, ProviderAdapter, TextToSpeechAdapter, SpeechToTextAdapter } from '../types.js'; /** Default TTS model when `ElevenLabsConfig.defaultTtsModelId` is unset. */ export declare const DEFAULT_TTS_MODEL_ID = "eleven_multilingual_v2"; /** Default voice when no voice id is encoded into the model string and no `opts.voice` override. */ export declare const DEFAULT_VOICE_ID = "21m00Tcm4TlvDq8ikWAM"; export interface ElevenLabsConfig { apiKey: string; /** * Override `https://api.elevenlabs.io`. Useful for proxying through a * gateway or for self-hosted ElevenLabs-compatible APIs. */ baseUrl?: string; /** * The TTS model id to send in the request body. Defaults to * `eleven_multilingual_v2`. Override per-deployment when piloting a * newer model (e.g. `eleven_turbo_v2_5` for lower-latency runs). */ defaultTtsModelId?: string; } export declare class ElevenLabsProvider implements ProviderFactory { readonly name = "elevenlabs"; private readonly config; constructor(config: ElevenLabsConfig); create(_model: string): ProviderAdapter; createTts(model: string): TextToSpeechAdapter; createStt(model: string): SpeechToTextAdapter; } //# sourceMappingURL=elevenlabs.d.ts.map