Skip to main content

Gladia Python SDK

A Python SDK for the Gladia API.

Requirements

You need Python 3.10+ for this package.

Installation

pip install gladiaio-sdk

# or with uv

uv add gladiaio-sdk

Usage

Import GladiaClient and create an instance.

Provide an API key with api_key or the GLADIA_API_KEY environment variable. Get your API key in under a minute.

You can also set GLADIA_API_URL. For live sessions, GLADIA_REGION (eu-west / us-west) is passed only on session creation (POST /v2/live).

Sync client

from gladiaio_sdk import GladiaClient

gladia_client = GladiaClient(api_key="your-api-key")

Pre-recorded transcription

transcribe() accepts a path, Path, binary file object, or http(s) URL. It uploads when needed, then polls until the job completes.

from gladiaio_sdk import GladiaClient

gladia_client = GladiaClient(api_key="your-api-key")

transcription = gladia_client.prerecorded().transcribe(
    "audio.mp3",
    {
        "language_config": {
            "languages": ["en"],
        },
    },
)

print(transcription.result.transcription.full_transcript)

See all the supported languages here!

Pass the options as the second argument to enable all the features from Audio intelligence — diarization, translation, PII redaction, and more.

Async pre-recorded

Use prerecorded_async() and await the same methods. Options match the sync API.

import asyncio

from gladiaio_sdk import GladiaClient


async def main() -> None:
    gladia_client = GladiaClient(api_key="your-api-key")

    transcription = await gladia_client.prerecorded_async().transcribe(
        "audio.mp3",
        {
            "language_config": {
                "languages": ["en"],
            },
        },
    )

    print(transcription.result.transcription.full_transcript)


asyncio.run(main())

Live transcription

Get a live client from your GladiaClient:

live_client = gladia_client.live()

Async version:

live_client = gladia_client.live_async()
from gladiaio_sdk import (
    LiveV2EndedMessage,
    LiveV2InitRequest,
    LiveV2InitResponse,
    LiveV2LanguageConfig,
    LiveV2MessagesConfig,
    LiveV2WebSocketMessage,
)

live_session = live_client.start_session(
    LiveV2InitRequest(
        model="solaria-1",
        encoding="wav/pcm",
        sample_rate=16000,
        bit_depth=16,
        channels=1,
        language_config=LiveV2LanguageConfig(
            languages=["en"],
        ),
        messages_config=LiveV2MessagesConfig(
            receive_partial_transcripts=True,
        ),
    )
)


@live_session.on("message")
def on_message(message: LiveV2WebSocketMessage):
    if message.type == "transcript":
        print(f"{'F' if message.data.is_final else 'P'} | {message.data.utterance.text.strip()}")


@live_session.once("started")
def on_started(response: LiveV2InitResponse):
    print(f"Session {response.id} started")


@live_session.on("error")
def on_error(error: Exception):
    print(f"An error occurred during live session: {error}")


@live_session.once("ended")
def on_ended(ended: LiveV2EndedMessage):
    print(f"Session {live_session.session_id} ended")


live_session.send_audio(audio_bytes)
live_session.stop_recording()

Use LiveV2InitRequest fields for realtime/post-processing options — see Live STT features and the live init API.

Async live

Same session API; use live_async() and run under asyncio.run or your app loop:

import asyncio

from gladiaio_sdk import (
    GladiaClient,
    LiveV2EndedMessage,
    LiveV2InitRequest,
    LiveV2InitResponse,
    LiveV2LanguageConfig,
    LiveV2MessagesConfig,
    LiveV2WebSocketMessage,
)


async def main() -> None:
    gladia_client = GladiaClient(api_key="your-api-key")
    live_client = gladia_client.live_async()
    session_done = asyncio.Event()

    live_session = live_client.start_session(
        LiveV2InitRequest(
            model="solaria-1",
            encoding="wav/pcm",
            sample_rate=16000,
            bit_depth=16,
            channels=1,
            language_config=LiveV2LanguageConfig(languages=["en"]),
            messages_config=LiveV2MessagesConfig(receive_partial_transcripts=True),
        )
    )

    @live_session.on("message")
    def on_message(message: LiveV2WebSocketMessage):
        if message.type == "transcript":
            print(f"{'F' if message.data.is_final else 'P'} | {message.data.utterance.text.strip()}")

    @live_session.once("started")
    def on_started(response: LiveV2InitResponse):
        print(f"Session {response.id} started")

    @live_session.on("error")
    def on_error(error: Exception):
        print(f"An error occurred during live session: {error}")
        session_done.set()

    @live_session.once("ended")
    def on_ended(ended: LiveV2EndedMessage):
        print(f"Session {live_session.session_id} ended")
        session_done.set()

    live_session.send_audio(audio_bytes)
    live_session.stop_recording()

    await session_done.wait()


asyncio.run(main())

When you need the session id from an async session: await live_session.get_session_id(). For a sync session, use live_session.session_id after started.

Documentation

License

MIT

Release files for gladiaio-sdk 2.0.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for gladiaio-sdk 2.0.0
File Size Uploaded
gladiaio_sdk-2.0.0.tar.gz 55.7 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for gladiaio-sdk 2.0.0
File Interpreter ABI Platform
gladiaio_sdk-2.0.0-py3-none-any.whl Python 3 none any Details

Total release size: 106.1 kB

Release files / gladiaio_sdk-2.0.0.tar.gz

Download URL gladiaio_sdk-2.0.0.tar.gz
Size 55.7 kB
Tags Source
SHA-256 checksum
How to use checksums
2bced6bd69db2b1d57d72b97354c9a8a7e0023050f0a521c5e2c42afd0ebcd0d
BLAKE2b-256 checksum
How to use checksums
494450c5221df9afc7134502812455d12d00e50dad8d8f6083e59e368abfdebb
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release files / gladiaio_sdk-2.0.0-py3-none-any.whl

Download URL gladiaio_sdk-2.0.0-py3-none-any.whl
Size 50.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
6280a649e750d84d7cab36ba9bd05e3553b677fe471389fdfaac8dc69d0f7766
BLAKE2b-256 checksum
How to use checksums
3a38b8b3d623f58f1c9f03c36b03317ecf7367b2183f1e239f49621689d4db0f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via uv/0.12.12 {"installer":{"name":"uv","version":"0.12.12","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

Release history Release notifications | RSS feed

2.1.0

2 release files

This release

2.0.0 This release

2 release files

1.0.5

2 release files

1.0.4

2 release files

1.0.3

2 release files

1.0.2

2 release files

1.0.1

2 release files

1.0.0

2 release files

0.4.0

2 release files

0.3.1

2 release files

0.3.0

2 release files

0.2.0

2 release files

0.1.1

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page