litellm/tests/unit/llms/elevenlabs
jorge-gbs 6704ee9ea3
feat(elevenlabs): add scribe_v2_realtime realtime transcription (#48984)
* feat(elevenlabs): add scribe_v2_realtime realtime transcription

* fix(elevenlabs): record realtime refusals, stream unspaced partials, probe health over the websocket

* fix(elevenlabs): hold back the trailing character when streaming unspaced partials

* fix(elevenlabs): hold back provisional trailing punctuation in unspaced partials

* chore(elevenlabs): ruff format the realtime config and mark ElevenLabs realtime in provider endpoint support

* fix(elevenlabs): price scribe_v2_realtime at the published $0.22 per hour

* refactor(elevenlabs): return rejected session updates as values and raise only at the session boundary

* fix(elevenlabs): bill the keyterm add-on, honor clear, skip empty commits, and stream full deltas

Keyterm sessions also bill the realtime keyterm add-on from a new cost map entry. input_audio_buffer.clear commits the pending audio and drops that segment's transcript, and a commit with no new audio is not forwarded, since ElevenLabs closes the session on it

The relay reports session_not_configured once the pre-setup buffer fills. Deltas now add up to the completed transcript, including mixed-script text, and ElevenLabs 4xx errors reach the client as invalid_request_error

* test(elevenlabs): give the shared get_complete_url test the realtime model name

* fix(elevenlabs): keep short commits alive and bill turns before sending them

Pad a commit or clear with under 0.3 s of new audio with silence, since ElevenLabs closes the session on it
Drop only the cleared commit's transcript, in commit order
Read realtime support from the cost map and send the deployment's model id
Log each provider batch's transcripts and billed seconds before any client send, so a dropped client is still billed
Map client-caused ElevenLabs errors to 4xx, import websockets lazily, and keep the port reason in the shared URL helper error

* fix(elevenlabs): match clears to their own commits, read realtime health mode from the catalog, and log usage before client sends

- Track every forwarded commit in order, so a clear drops only its own segment's transcript, also after an unanswered commit or a second clear
- Pick the realtime health check from /v1/realtime in the model's supported_endpoints instead of the model name
- Log completed transcription usage for a provider batch before any of the batch is sent, so a client disconnect mid-batch cannot drop billed audio; the token-limit drop path only counts those events

* fix(elevenlabs): send an empty completed transcript for a commit with no speech

* fix(elevenlabs): keep the realtime catalog lookup and pre-send usage logging fully typed

* fix(elevenlabs): bill keyterms at $0.05 per hour, keep idle realtime sessions open, and log ElevenLabs error text

ElevenLabs prices keyterm prompting at $0.05 per hour on realtime, so the add-on entry drops from $0.08 and no longer lists /v1/realtime, which let a deployment route to it as a model. ElevenLabs closes a session after about 15 s without client messages, so the backend sends an empty audio chunk after 5 s of client silence, which bills no audio. ElevenLabs error text goes to the proxy log at warning while the client keeps the generic message

* fix(realtime): keep the pre-setup buffer silent for other bridges, end cleared ElevenLabs turns, and honor drop_params for the session model

The relay no longer sends session_not_configured when the pre-setup buffer fills, restoring base behavior for Meta, Vertex Chirp and Gemini Live clients that already sent session.update

A cleared ElevenLabs turn now ends with speech_stopped and input_audio_buffer.cleared

A session.update naming another transcription model is refused with the model to send, or ignored when drop_params is set

* fix(elevenlabs): hold back partials only while the oldest pending commit is a clear

---------

Co-authored-by: mateo-berri <277851410+mateo-berri@users.noreply.github.com>
2026-11-25 03:15:34 +00:00
..
audio_transcription
realtime feat(elevenlabs): add scribe_v2_realtime realtime transcription (#48984) 2026-11-25 03:15:34 +00:00
__init__.py
test_elevenlabs_text_to_speech_transformation.py