ReqLLM. Providers. ElevenLabs
(ReqLLM v1.14.0)
View Source
ElevenLabs provider for text-to-speech and speech-to-text transcription.
Implementation
ElevenLabs uses different API formats from OpenAI-compatible providers:
- Text-to-speech uses
/v1/text-to-speech/{voiceId}withxi-api-key - Speech-to-text uses multipart
POST /v1/speech-to-text - Authentication uses
xi-api-keyheader instead of Bearer auth
Supported Operations
ElevenLabs supports:
:speechfor text-to-speech:transcriptionfor speech-to-text
Chat and embedding operations are not supported.
Configuration
# Add to .env file (automatically loaded)
ELEVENLABS_API_KEY=sk_...Usage
{:ok, result} = ReqLLM.speak(
%{id: "eleven_multilingual_v2", provider: :elevenlabs},
"Hello, world!",
voice: "21m00Tcm4TlvDq8ikWAM"
)
{:ok, result} = ReqLLM.transcribe(
%{id: "scribe_v2", provider: :elevenlabs},
"/path/to/audio.mp3"
)Provider Options
ElevenLabs-specific options can be passed via provider_options:
Speech options:
stability- Voice stability (0.0 to 1.0)similarity_boost- Voice similarity boost (0.0 to 1.0)style- Style exaggeration (0.0 to 1.0)speed- Speech speed (0.5 to 2.0)
Transcription options:
enable_loggingtag_audio_eventsnum_speakerstimestamps_granularitydiarizediarization_thresholdfile_formatcloud_storage_urlwebhookwebhook_idtemperatureseeduse_multi_channelwebhook_metadataentity_detectionkeyterms
Summary
Functions
Default implementation of attach/3.
Default implementation of attach_stream/4.
Default implementation of build_body/1.
Default implementation of decode_response/1.
Default implementation of decode_stream_event/2.
Callback implementation for ReqLLM.Provider.default_env_key/0.
Default implementation of encode_body/1.
Default implementation of extract_usage/2.
Default implementation of prepare_request/4.
Default implementation of translate_options/3.
Functions
Default implementation of attach/3.
Sets up Bearer token authentication and standard pipeline steps.
Default implementation of attach_stream/4.
Builds complete streaming requests using OpenAI-compatible format.
Default implementation of build_body/1.
Builds request body using OpenAI-compatible format for chat and embedding operations.
Default implementation of decode_response/1.
Handles success/error responses with standard ReqLLM.Response creation.
Default implementation of decode_stream_event/2.
Decodes SSE events using OpenAI-compatible format.
Callback implementation for ReqLLM.Provider.default_env_key/0.
Default implementation of encode_body/1.
Encodes request body using OpenAI-compatible format for chat and embedding operations.
Default implementation of extract_usage/2.
Extracts usage data from standard usage field in response body.
Default implementation of prepare_request/4.
Handles :chat, :object, and :embedding operations using OpenAI-compatible patterns.
Default implementation of translate_options/3.
Pass-through implementation that returns options unchanged.