ReqLLM.Providers.ElevenLabs (ReqLLM v1.12.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} with xi-api-key
  • Speech-to-text uses multipart POST /v1/speech-to-text
  • Authentication uses xi-api-key header instead of Bearer auth

Supported Operations

ElevenLabs supports:

  • :speech for text-to-speech
  • :transcription for 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_logging
  • tag_audio_events
  • num_speakers
  • timestamps_granularity
  • diarize
  • diarization_threshold
  • file_format
  • cloud_storage_url
  • webhook
  • webhook_id
  • temperature
  • seed
  • use_multi_channel
  • webhook_metadata
  • entity_detection
  • keyterms

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.

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

attach(request, model_input, user_opts)

Default implementation of attach/3.

Sets up Bearer token authentication and standard pipeline steps.

attach_stream(model, context, opts, finch_name)

Default implementation of attach_stream/4.

Builds complete streaming requests using OpenAI-compatible format.

base_url()

build_body(request)

Default implementation of build_body/1.

Builds request body using OpenAI-compatible format for chat and embedding operations.

decode_response(request_response)

Default implementation of decode_response/1.

Handles success/error responses with standard ReqLLM.Response creation.

decode_stream_event(event, model)

Default implementation of decode_stream_event/2.

Decodes SSE events using OpenAI-compatible format.

default_base_url()

default_env_key()

Callback implementation for ReqLLM.Provider.default_env_key/0.

encode_body(request)

Default implementation of encode_body/1.

Encodes request body using OpenAI-compatible format for chat and embedding operations.

extract_usage(body, model)

Default implementation of extract_usage/2.

Extracts usage data from standard usage field in response body.

prepare_request(operation, model_spec, input, opts)

Default implementation of prepare_request/4.

Handles :chat, :object, and :embedding operations using OpenAI-compatible patterns.

provider_extended_generation_schema()

provider_id()

provider_schema()

supported_provider_options()

translate_options(operation, model, opts)

Default implementation of translate_options/3.

Pass-through implementation that returns options unchanged.