# Migrate from AssemblyAI to Gladia

Last updated: 2026-11-12

AssemblyAI's Universal Streaming (v3) and Gladia's live API both stream raw audio over a WebSocket. AssemblyAI sends a `Turn` message that grows until the turn ends; Gladia sends a `transcript` per utterance, partial then final, and an `end_of_turn` message when the speaker is done. Pre-recorded transcription is a job on both sides. 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](/introduction/sdks/)).

## At a glance

|  | AssemblyAI | Gladia |
|---|---|---|
| Authentication | `Authorization: <key>`, or a temporary `token` | `x-gladia-key: <key>`; the WebSocket `url` carries its own token |
| Live | `wss://streaming.assemblyai.com/v3/ws?…`, settings in the query string | `POST /v2/live` with a JSON body, then its WebSocket `url` |
| Pre-recorded | `POST /v2/upload`, `POST /v2/transcript`, poll or webhook | `POST /v2/upload`, `POST /v2/pre-recorded`, poll or callback |
| Audio | binary frames | binary frames |
| Models | `universal-streaming-english`, `universal-streaming-multilingual`, … | `solaria-3` (multilingual), `trantoria-1` (lowest latency) ([Models](/introduction/models/)) |

## Live transcription

### Before and after

A typical AssemblyAI v3 stream (Python, its WebSocket with the `websockets` library):

```python
# AssemblyAI (before)
import json

import websockets

URL = "wss://streaming.assemblyai.com/v3/ws?sample_rate=16000&encoding=pcm_s16le&format_turns=true"

async def stream(key, chunks):
    async with websockets.connect(URL, additional_headers={"Authorization": key}) as ws:
        for chunk in chunks:
            await ws.send(chunk)  # binary audio
        await ws.send(json.dumps({"type": "Terminate"}))
        async for raw in ws:  # {"type": "Turn", "transcript": ..., "end_of_turn": ..., "turn_is_formatted": ...}
            message = json.loads(raw)
            if message["type"] == "Turn" and message["end_of_turn"]:
                print(message["transcript"])
```

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_assemblyai.py call.wav`.

```python title="from_assemblyai.py"
# pip install -U "gladiaio-sdk>=2.2"
import os
import sys
import threading
import 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
    },
    "end_of_turn": True
}

client = GladiaClient(api_key=API_KEY, api_url=API_URL)
session = client.live_v2().start_session(config)  # POST /v2/live, then its WebSocket
ended, errors = threading.Event(), []

@session.on("message")
def on_message(message):
    if message.type == "transcript":  # AssemblyAI's "Turn"
        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 ends
session.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 chunk
for start in range(0, len(audio), step):
    session.send_audio(audio[start : start + step])  # binary frames, as before
session.stop_recording()  # AssemblyAI's "Terminate"

ended.wait(timeout=60)
sys.exit(1 if errors or not ended.is_set() else 0)
```

The init body the program sends, as JSON:

```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
  },
  "end_of_turn": true
}
```

### Parameters

| AssemblyAI | Gladia | Note |
|---|---|---|
| `speech_model` | `model` | `solaria-3` or `trantoria-1` |
| `sample_rate` | `sample_rate` |  |
| `encoding=pcm_s16le` | `encoding: "wav/pcm"`, `bit_depth: 16` |  |
| `encoding=pcm_mulaw` | `encoding: "wav/ulaw"`, `bit_depth: 8` | [Phone calls](/live/telephony/) |
| `language_codes` | `language_config.languages` |  |
| `format_turns=true` | always formatted: punctuation on by default | `numerals: true` for digits |
| `end_of_turn_confidence_threshold` | `end_of_turn: {"eot_threshold": …}` | [End of turn](/live/end-of-turn/) |
| `min_turn_silence` (ms) | `end_of_turn: {"min_end_of_turn_silence_when_confident": …}` (ms) | [End of turn](/live/end-of-turn/) |
| `max_turn_silence` (ms) | `end_of_turn: {"stop_s": …}` (s) | the silence that ends the turn anyway |
| `keyterms_prompt` | `realtime_processing.custom_vocabulary` and `realtime_processing.custom_vocabulary_config` | [Custom vocabulary](/features/custom-vocabulary/) |

### Messages

| AssemblyAI | Gladia | Note |
|---|---|---|
| `Begin` | `start_recording` | with `receive_lifecycle_events` |
| `Turn`, `end_of_turn: false` | `transcript`, `data.is_final: false` | Gladia's partials are per utterance, not the whole turn so far |
| `Turn`, `end_of_turn: true` | the last final `transcript` of the turn, then `end_of_turn` |  |
| `Turn.transcript` | `data.utterance.text` |  |
| `Turn.words` | `data.utterance.words` |  |
| `Termination` | `end_session` | with `receive_lifecycle_events` (off by default) |
| `ForceEndpoint` (you send) | `{"type": "finalize"}` | [Finalize now](/live/finalize/) |
| `UpdateConfiguration` (you send) | `{"type": "session_config", …}` | [Change settings mid-session](/live/session-config/) |
| `Terminate` (you send) | `{"type": "stop_recording"}` | the SDK's `stop_recording()` |

## Pre-recorded (batch) transcription

Both run a job: upload the file, create the transcription with its URL, then poll it or receive a webhook. The names change.

### Before and after

A typical AssemblyAI file transcription (Python, its REST API with `requests`):

```python
# AssemblyAI (before)
import time

import requests

BASE = "https://api.assemblyai.com/v2"

def transcribe(key, path):
    headers = {"authorization": key}
    with open(path, "rb") as audio:
        upload_url = requests.post(f"{BASE}/upload", headers=headers, data=audio).json()["upload_url"]
    job = requests.post(
        f"{BASE}/transcript",
        headers=headers,
        json={"audio_url": upload_url, "language_code": "en", "speaker_labels": True},
    ).json()
    while job["status"] not in ("completed", "error"):
        time.sleep(3)
        job = requests.get(f"{BASE}/transcript/{job['id']}", headers=headers).json()
    if job["status"] == "error":
        raise RuntimeError(job["error"])
    print(job["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](/pre-recorded/transcribe-a-file/)). Put your Gladia API key in `GLADIA_API_KEY`, then run `python from_assemblyai_file.py call.wav`.

```python title="from_assemblyai_file.py"
# pip install requests
import os
import sys
import 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"]}  # AssemblyAI: "authorization: <key>"
TIMEOUT = 60  # seconds an HTTP call may take
POLL_EVERY = 1  # seconds between two reads of the job
ENDED = ("done", "error")  # the statuses a job ends with

# 1. Upload the file (AssemblyAI's POST /v2/upload)
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 body
created = requests.post(
    f"{API_URL}/v2/pre-recorded",
    headers=HEADERS,
    json={
        "audio_url": upload.json()["audio_url"],
        "model": "solaria-3",  # AssemblyAI's default model
        "language_config": {"languages": ["en"]},  # language_code
        "diarization": True,  # speaker_labels
    },
    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 job
```

To be called back rather than poll, add a callback to the job: Gladia calls your URL when the job ends ([Pre-recorded callbacks](/pre-recorded/callbacks/)). The job's body, with a callback:

```json
{
  "audio_url": "https://eu1.api.gladia.io/file/0199d7a2-0000-7000-8000-00000000f11e",
  "language_config": {
    "languages": [
      "en"
    ]
  },
  "diarization": true,
  "sentiment_analysis": true,
  "callback": true,
  "callback_config": {
    "url": "https://example.com/gladia/callback"
  }
}
```

| AssemblyAI | Gladia | Note |
|---|---|---|
| `POST /v2/upload` → `upload_url` | `POST /v2/upload` → `audio_url` | multipart, the `audio` field |
| `POST /v2/transcript` | `POST /v2/pre-recorded` |  |
| `GET /v2/transcript/{id}`, `status: completed` | `GET /v2/pre-recorded/{id}`, `status: done` |  |
| `webhook_url` | `callback: true`, `callback_config.url` | [Pre-recorded callbacks](/pre-recorded/callbacks/) |
| `speaker_labels` | `diarization` |  |
| `language_detection` | `language_config: {"languages": []}` |  |
| `keyterms_prompt`, `word_boost` | `custom_vocabulary`, `custom_vocabulary_config` |  |
| `redact_pii` | `pii_redaction` |  |
| `entity_detection` | `named_entity_recognition` |  |
| `sentiment_analysis` | `sentiment_analysis` |  |
| `text` | `result.transcription.full_transcript` |  |
| `utterances` | `result.transcription.utterances` |  |

## Differences to know

- **A session is opened over HTTP first.** `POST /v2/live` with the session's settings returns a WebSocket `url` that 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.3` is 300 ms ([Endpointing](/live/endpointing/)).
- **Punctuation and casing are on by default** ([Punctuation](/features/punctuation/)); numbers as digits are `numerals: true` ([Numbers as digits](/features/numerals/)).
- **Audio is acknowledged once transcribed**, not once received: keep it until then to resend it after a network drop ([Reconnections](/live/reconnections/)). The SDKs do it for you.
- **Partials are per utterance.** AssemblyAI's `Turn` repeats the whole turn so far; a Gladia partial is the utterance being spoken. Join the finals of a turn to rebuild its text.
- **Statuses differ**: AssemblyAI's `queued`, `processing`, `completed`, `error`; Gladia's `queued`, `processing`, `done`, `error`.

## Related pages

- [Quickstart: live speech-to-text in five minutes](/introduction/quickstart/)
- [Live transcription over WebSocket: how a session works](/live/how-it-works/)
- [Pre-recorded (batch) transcription of an audio file](/pre-recorded/transcribe-a-file/)
- [Recommended parameters](/live/recommended-parameters/)
