UNPKG

@ai-sdk/elevenlabs

Version:

The **[ElevenLabs provider](https://ai-sdk.dev/providers/ai-sdk-providers/elevenlabs)** for the [AI SDK](https://ai-sdk.dev/docs) contains language model support for the ElevenLabs chat and completion APIs and embedding model support for the ElevenLabs em

123 lines (114 loc) 4.83 kB
import { TranscriptionModelV3, ProviderV3, SpeechModelV3 } from '@ai-sdk/provider'; import { FetchFunction } from '@ai-sdk/provider-utils'; import { z } from 'zod/v4'; type ElevenLabsConfig = { provider: string; url: (options: { modelId: string; path: string; }) => string; headers: () => Record<string, string | undefined>; fetch?: FetchFunction; generateId?: () => string; }; type ElevenLabsTranscriptionModelId = 'scribe_v1' | 'scribe_v1_experimental' | (string & {}); declare const elevenLabsTranscriptionModelOptionsSchema: z.ZodObject<{ languageCode: z.ZodOptional<z.ZodNullable<z.ZodString>>; tagAudioEvents: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodBoolean>>>; numSpeakers: z.ZodOptional<z.ZodNullable<z.ZodNumber>>; timestampsGranularity: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodEnum<{ none: "none"; word: "word"; character: "character"; }>>>>; diarize: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodBoolean>>>; fileFormat: z.ZodDefault<z.ZodOptional<z.ZodNullable<z.ZodEnum<{ pcm_s16le_16: "pcm_s16le_16"; other: "other"; }>>>>; }, z.core.$strip>; type ElevenLabsTranscriptionModelOptions = z.infer<typeof elevenLabsTranscriptionModelOptionsSchema>; interface ElevenLabsTranscriptionModelConfig extends ElevenLabsConfig { _internal?: { currentDate?: () => Date; }; } declare class ElevenLabsTranscriptionModel implements TranscriptionModelV3 { readonly modelId: ElevenLabsTranscriptionModelId; private readonly config; readonly specificationVersion = "v3"; get provider(): string; constructor(modelId: ElevenLabsTranscriptionModelId, config: ElevenLabsTranscriptionModelConfig); private getArgs; doGenerate(options: Parameters<TranscriptionModelV3['doGenerate']>[0]): Promise<Awaited<ReturnType<TranscriptionModelV3['doGenerate']>>>; } type ElevenLabsSpeechModelId = 'eleven_v3' | 'eleven_multilingual_v2' | 'eleven_flash_v2_5' | 'eleven_flash_v2' | 'eleven_turbo_v2_5' | 'eleven_turbo_v2' | 'eleven_monolingual_v1' | 'eleven_multilingual_v1' | (string & {}); type ElevenLabsSpeechVoiceId = string; interface ElevenLabsProvider extends ProviderV3 { (modelId: 'scribe_v1', settings?: {}): { transcription: ElevenLabsTranscriptionModel; }; /** * Creates a model for transcription. */ transcription(modelId: ElevenLabsTranscriptionModelId): TranscriptionModelV3; /** * Creates a model for speech generation. */ speech(modelId: ElevenLabsSpeechModelId): SpeechModelV3; /** * @deprecated Use `embeddingModel` instead. */ textEmbeddingModel(modelId: string): never; } interface ElevenLabsProviderSettings { /** * API key for authenticating requests. */ apiKey?: string; /** * Custom headers to include in the requests. */ headers?: Record<string, string>; /** * Custom fetch implementation. You can use it as a middleware to intercept requests, * or to provide a custom fetch implementation for e.g. testing. */ fetch?: FetchFunction; } /** * Create an ElevenLabs provider instance. */ declare function createElevenLabs(options?: ElevenLabsProviderSettings): ElevenLabsProvider; /** * Default ElevenLabs provider instance. */ declare const elevenlabs: ElevenLabsProvider; declare const elevenLabsSpeechModelOptionsSchema: z.ZodObject<{ languageCode: z.ZodOptional<z.ZodString>; voiceSettings: z.ZodOptional<z.ZodObject<{ stability: z.ZodOptional<z.ZodNumber>; similarityBoost: z.ZodOptional<z.ZodNumber>; style: z.ZodOptional<z.ZodNumber>; useSpeakerBoost: z.ZodOptional<z.ZodBoolean>; }, z.core.$strip>>; pronunciationDictionaryLocators: z.ZodOptional<z.ZodArray<z.ZodObject<{ pronunciationDictionaryId: z.ZodString; versionId: z.ZodOptional<z.ZodString>; }, z.core.$strip>>>; seed: z.ZodOptional<z.ZodNumber>; previousText: z.ZodOptional<z.ZodString>; nextText: z.ZodOptional<z.ZodString>; previousRequestIds: z.ZodOptional<z.ZodArray<z.ZodString>>; nextRequestIds: z.ZodOptional<z.ZodArray<z.ZodString>>; applyTextNormalization: z.ZodOptional<z.ZodEnum<{ auto: "auto"; on: "on"; off: "off"; }>>; applyLanguageTextNormalization: z.ZodOptional<z.ZodBoolean>; enableLogging: z.ZodOptional<z.ZodBoolean>; }, z.core.$strip>; type ElevenLabsSpeechModelOptions = z.infer<typeof elevenLabsSpeechModelOptionsSchema>; declare const VERSION: string; export { type ElevenLabsProvider, type ElevenLabsProviderSettings, type ElevenLabsSpeechModelId, type ElevenLabsSpeechModelOptions, type ElevenLabsSpeechVoiceId, type ElevenLabsTranscriptionModelOptions, VERSION, createElevenLabs, elevenlabs };