Skip to main content
This step-by-step guide shows how to switch your realtime transcription from AssemblyAI to Gladia with minimal code changes. It highlights equivalences, subtle differences, and drop‑in replacements so you can migrate quickly and confidently, without any regressions.

Step-by-step guide

Install the SDK

Install the official SDKs to enable realtime streaming. That’s all you need to get started in Python or TypeScript. For AssemblyAI :
pip install assemblyai
For Gladia:
pip install gladiaio-sdk

Initialize the client

Create and authenticate the client that manages your live connection. The shape is the same idea across providers—just swap the client and key. For AssemblyAI :
from assemblyai.streaming.v3 import StreamingClient, StreamingClientOptions

api_key = "<YOUR_ASSEMBLYAI_API_KEY>"

assemblyClient = StreamingClient(
    StreamingClientOptions(
        api_key=api_key,
        api_host="streaming.assemblyai.com",
    )
)
For Gladia :
from gladiaio_sdk import GladiaClient

gladia_client = GladiaClient(api_key="<YOUR_GLADIA_API_KEY>")

Configure the session

Choose the model, audio format, and language options your app needs. Most parameters map one‑to‑one, so your existing settings carry over naturally.

AssemblyAI to Gladia parameter mapping

AssemblyAIGladiaNotes / Example
modelmodelChoose the latest Gladia model (“solaria-1”).
encodingencodingMatch the actual audio format (e.g., linear16wav/pcm).
bit_depthChoose the bit depth value from your audio
sample_ratesample_rateSame unit (Hz).
channelschannelsSame meaning.
interim_resultsmessages_config.receive_partial_transcriptsSet true to receive partials messages.
endpointingendpointing; maximum_duration_without_endpointingPort thresholds and consider a hard cap.
languagelanguage_config.languages (+ code_switching)Pass one or more languages; enable switching when multiple languages are spoken.
Gladia config example
{
  "model": "solaria-1",
  "encoding": "wav/pcm",
  "bit_depth": 16,
  "sample_rate": 16000,
  "channels": 1,
  "language_config": { "languages": ["en"], "code_switching": false },
  "messages_config": {
    "receive_partial_transcripts": true,
    "receive_final_transcripts": true
  },
  "endpointing": 0.8,
  "maximum_duration_without_endpointing": 30,
  "realtime_processing": {
    "custom_vocabulary": false,
    "custom_spelling": false
  }
}
See the full schema in the live init reference.

Start the transcription session

Open a live transcription session using your configuration. The flow is the same as with AssemblyAI: establish the WebSocket and get ready to stream audio. For AssemblyAI :
from assemblyai.streaming.v3 import StreamingParameters

assemblyClient.connect(
    StreamingParameters(
        sample_rate=16000,
        format_turns=True,
    )
)
For Gladia :
gladia_session = gladia_client.live_v2().start_session(gladia_config)

Send audio chunks

Stream audio frames to the session as they are produced. Both SDKs accept small chunks continuously—keep your existing chunking logic. For AssemblyAI :
assemblyClient.stream(audio_chunk)
For Gladia :
gladia_session.send_audio(audio_chunk)

Read transcription messages

After audio is flowing, subscribe to transcript and lifecycle events. The mapping below shows how to translate AssemblyAI listeners to Gladia in a single place. Event mapping from AssemblyAI to Gladia:
  • Transcript → listen to Gladia message and branch on message.data.is_final to separate partial vs final results.
  • Open/Close/Error → map to Gladia started/ended/error.
In practice, subscribe once to message and use the is_final flag instead of wiring separate listeners—less boilerplate, same control. To receive partials, enable messages_config.receive_partial_transcripts: true in your init config. For AssemblyAI :
from typing import Type

from assemblyai.streaming.v3 import (
    BeginEvent,
    StreamingClient,
    StreamingError,
    StreamingEvents,
    StreamingSessionParameters,
    TerminationEvent,
    TurnEvent,
)


def on_begin(self: Type[StreamingClient], event: BeginEvent):
    print(f"Session started: {event.id}")


def on_turn(self: Type[StreamingClient], event: TurnEvent):
    print(f"{event.transcript} ({event.end_of_turn})")

    if event.end_of_turn and not event.turn_is_formatted:
        params = StreamingSessionParameters(
            format_turns=True,
        )
        self.set_params(params)


def on_terminated(self: Type[StreamingClient], event: TerminationEvent):
    print(
        f"Session terminated: {event.audio_duration_seconds} seconds of audio processed"
    )


def on_error(self: Type[StreamingClient], error: StreamingError):
    print(f"Error occurred: {error}")


client.on(StreamingEvents.Begin, on_begin)
client.on(StreamingEvents.Turn, on_turn)
client.on(StreamingEvents.Termination, on_terminated)
client.on(StreamingEvents.Error, on_error)
For Gladia :
from gladiaio_sdk import (
    LiveV2WebSocketMessage,
    LiveV2InitResponse,
    LiveV2EndedMessage,
)

@live_session.on("message")
def on_message(message: LiveV2WebSocketMessage):
    # Partial and final transcripts are delivered here
    # filter them with message.data.is_final field
    print(message)

@live_session.once("started")
def on_started(_response: LiveV2InitResponse):
    print("Session started. Listening...")

@live_session.once("ended")
def on_ended(_ended: LiveV2EndedMessage):
    print("Session ended.")

@live_session.on("error")
def on_error(error: Exception):
    print(f"Error: {error}")