Migrate from ElevenLabs to Gladia
ElevenLabs’ realtime speech-to-text and Gladia’s live API both use a WebSocket. ElevenLabs sends each audio chunk as base64 inside a JSON input_audio_chunk message and returns partial_transcript and committed_transcript; Gladia takes raw binary frames and returns transcript messages, partial then final. Batch transcription becomes a pre-recorded job. The Gladia SDKs (gladiaio-sdk for Python, @gladiaio/sdk for JavaScript) open the session, keep the audio until it is transcribed and reconnect without losing a word (SDKs).
At a glance
Section titled “At a glance”| ElevenLabs | Gladia | |
|---|---|---|
| Authentication | xi-api-key: <key>, or a single-use token |
x-gladia-key: <key>; the WebSocket url carries its own token |
| Live | wss://api.elevenlabs.io/v1/speech-to-text/realtime?… |
POST /v2/live with a JSON body, then its WebSocket url |
| Pre-recorded | POST /v1/speech-to-text (multipart), the transcript in the answer or a webhook |
POST /v2/upload, POST /v2/pre-recorded, poll or callback |
| Audio | base64 in input_audio_chunk messages |
binary frames |
| Models | scribe_v2_realtime, scribe_v2 |
solaria-3 (multilingual), trantoria-1 (lowest latency) (Models) |
Live transcription
Section titled “Live transcription”Before and after
Section titled “Before and after”A typical ElevenLabs realtime stream (Python, its WebSocket with the websockets library):
# ElevenLabs (before)import base64import json
import websockets
URL = "wss://api.elevenlabs.io/v1/speech-to-text/realtime?model_id=scribe_v2_realtime&audio_format=pcm_16000&commit_strategy=vad"
async def stream(key, chunks): async with websockets.connect(URL, additional_headers={"xi-api-key": key}) as ws: for chunk in chunks: await ws.send(json.dumps({ "message_type": "input_audio_chunk", "audio_base_64": base64.b64encode(chunk).decode(), "commit": False, "sample_rate": 16000, })) async for raw in ws: # partial_transcript, committed_transcript message = json.loads(raw) if message["message_type"] == "committed_transcript": print(message["text"])With Gladia, the same stream: the SDK opens the session (POST /v2/live) and its WebSocket, and you send the same audio bytes. Put your Gladia API key in GLADIA_API_KEY, then run python from_elevenlabs.py call.wav.
# pip install -U "gladiaio-sdk>=2.2"import osimport sysimport threadingimport wave
from gladiaio_sdk import GladiaClient
API_URL = os.environ.get("GLADIA_API_URL", "https://eu1.api.gladia.io")API_KEY = os.environ["GLADIA_API_KEY"] # x-gladia-key, from Gladia Workspace
with wave.open(sys.argv[1]) as wav: # a 16-bit PCM WAV file rate, channels = wav.getframerate(), wav.getnchannels() audio = wav.readframes(wav.getnframes())
config = { "encoding": "wav/pcm", "sample_rate": rate, "bit_depth": 16, "channels": channels, "model": "solaria-3", "language_config": { "languages": [ "en" ] }, "messages_config": { "receive_partial_transcripts": True }}
client = GladiaClient(api_key=API_KEY, api_url=API_URL)session = client.live_v2().start_session(config) # POST /v2/live, then its WebSocketended, errors = threading.Event(), []
@session.on("message")def on_message(message): if message.type == "transcript": # ElevenLabs' "partial_transcript" and "committed_transcript" utterance = message.data.utterance print(("final " if message.data.is_final else "partial ") + utterance.text)
session.on("error", errors.append)session.once("ended", lambda _: ended.set())
# Stream once the socket is open: a stop sent while it opens can pass the audio queued until then.connected = threading.Event()session.once("connected", lambda _: connected.set())session.once("ended", lambda _: connected.set()) # a session that never connects endssession.on("error", lambda _: connected.set())if session.status == "connected": # it opened before the listener above connected.set()if not connected.wait(timeout=30) or errors or ended.is_set(): sys.exit(1) # no open session to stream to
step = rate * channels * 2 // 10 # 100 ms of audio per chunkfor start in range(0, len(audio), step): session.send_audio(audio[start : start + step]) # binary frames, as beforesession.stop_recording() # the end of the ElevenLabs stream
ended.wait(timeout=60)sys.exit(1 if errors or not ended.is_set() else 0)The init body the program sends, as JSON:
{ "encoding": "wav/pcm", "sample_rate": 16000, "bit_depth": 16, "channels": 1, "model": "solaria-3", "language_config": { "languages": [ "en" ] }, "messages_config": { "receive_partial_transcripts": true }}Parameters
Section titled “Parameters”| ElevenLabs | Gladia | Note |
|---|---|---|
model_id=scribe_v2_realtime |
model: "solaria-3" |
trantoria-1 for the lowest latency |
audio_format=pcm_16000 |
encoding: "wav/pcm", bit_depth: 16, sample_rate: 16000 |
|
audio_format=ulaw_8000 |
encoding: "wav/ulaw", bit_depth: 8, sample_rate: 8000 |
Phone calls |
language_code |
language_config.languages |
|
commit_strategy=vad, vad_silence_threshold_secs |
endpointing (s) |
Endpointing |
commit_strategy=turn_prediction |
end_of_turn: true |
End of turn |
keyterms |
realtime_processing.custom_vocabulary and realtime_processing.custom_vocabulary_config |
Custom vocabulary |
include_timestamps=true |
always: data.utterance.words |
|
entity_detection, entity_redaction |
named_entity_recognition, pii |
Named entities, PII redaction |
Messages
Section titled “Messages”| ElevenLabs | Gladia | Note |
|---|---|---|
session_started |
start_recording |
with receive_lifecycle_events |
partial_transcript |
transcript, data.is_final: false |
Partial transcripts |
committed_transcript |
transcript, data.is_final: true |
the text: data.utterance.text |
committed_transcript_with_timestamps |
the same final transcript: its words |
|
input_audio_chunk (you send) |
a binary frame of the raw audio | no base64, no JSON |
commit: true (you send) |
{"type": "finalize"} |
Finalize now |
Pre-recorded (batch) transcription
Section titled “Pre-recorded (batch) transcription”ElevenLabs transcribes a file in the request (or later through a webhook). Gladia runs a job on an uploaded file or a URL.
Before and after
Section titled “Before and after”A typical ElevenLabs file transcription (Python, its REST API with requests):
# ElevenLabs (before)import requests
def transcribe(key, path): with open(path, "rb") as audio: # multipart: the file and the options answer = requests.post( "https://api.elevenlabs.io/v1/speech-to-text", headers={"xi-api-key": key}, files={"file": audio}, data={"model_id": "scribe_v2", "language_code": "en", "diarize": "true"}, ) answer.raise_for_status() # the transcript is in the answer print(answer.json()["text"])With Gladia, the same file in three steps: upload it (POST /v2/upload), start a job with its audio_url (POST /v2/pre-recorded), then read the job (GET /v2/pre-recorded/{id}) until its status is done (Transcribe a file). Put your Gladia API key in GLADIA_API_KEY, then run python from_elevenlabs_file.py call.wav.
# pip install requestsimport osimport sysimport time
import requests
API_URL = os.environ.get("GLADIA_API_URL", "https://eu1.api.gladia.io")HEADERS = {"x-gladia-key": os.environ["GLADIA_API_KEY"]} # ElevenLabs: "xi-api-key: <key>"TIMEOUT = 60 # seconds an HTTP call may takePOLL_EVERY = 1 # seconds between two reads of the jobENDED = ("done", "error") # the statuses a job ends with
# 1. Upload the file (ElevenLabs takes the file in the request itself)with open(sys.argv[1], "rb") as audio: upload = requests.post(f"{API_URL}/v2/upload", headers=HEADERS, files={"audio": audio}, timeout=TIMEOUT)upload.raise_for_status()
# 2. Start the job on the uploaded file, the options in a JSON bodycreated = requests.post( f"{API_URL}/v2/pre-recorded", headers=HEADERS, json={ "audio_url": upload.json()["audio_url"], "model": "solaria-3", # model_id=scribe_v2 "language_config": {"languages": ["en"]}, # language_code=en "diarization": True, # diarize=true }, timeout=TIMEOUT,)created.raise_for_status()job_url = f"{API_URL}/v2/pre-recorded/{created.json()['id']}"
# 3. Read the job until it ends (or get a callback, below)while True: answer = requests.get(job_url, headers=HEADERS, timeout=TIMEOUT) answer.raise_for_status() job = answer.json() if job["status"] in ENDED: break time.sleep(POLL_EVERY)if job["status"] == "error": sys.exit(f"the job failed: {job.get('error_code')}")print(job["result"]["transcription"]["full_transcript"]) # the result is in the jobTo be called back rather than poll, add a callback to the job: Gladia calls your URL when the job ends (Pre-recorded callbacks). The job’s body, with a callback:
{ "audio_url": "https://eu1.api.gladia.io/file/0199d7a2-0000-7000-8000-00000000f11e", "language_config": { "languages": [ "en" ] }, "diarization": true, "callback": true, "callback_config": { "url": "https://example.com/gladia/callback" }}| ElevenLabs | Gladia | Note |
|---|---|---|
file (multipart) |
POST /v2/upload, then audio_url |
|
source_url |
audio_url |
|
model_id=scribe_v2 |
model (solaria-1 by default, or solaria-3) |
Transcribe a file |
language_code |
language_config.languages |
|
diarize, num_speakers |
diarization, diarization_config.max_speakers |
|
keyterms |
custom_vocabulary, custom_vocabulary_config |
|
webhook=true |
callback: true, callback_config.url |
Pre-recorded callbacks |
text |
result.transcription.full_transcript |
|
words[].speaker_id |
result.transcription.utterances[].speaker |
Differences to know
Section titled “Differences to know”- A session is opened over HTTP first.
POST /v2/livewith the session’s settings returns a WebSocketurlthat carries its own token: settings go in a JSON body, not in the WebSocket’s query string, and your API key never reaches the client that streams. The SDKs do both steps. - Endpointing is in seconds:
endpointing: 0.3is 300 ms (Endpointing). - Punctuation and casing are on by default (Punctuation); numbers as digits are
numerals: true(Numbers as digits). - Audio is acknowledged once transcribed, not once received: keep it until then to resend it after a network drop (Reconnections). The SDKs do it for you.
- Binary audio, no base64: a quarter less to send, and the format is set once in the init body, not on every chunk.