Soniox
SDKs

Soniox Python SDK

Python SDK for Soniox REST and realtime APIs.

This SDK lets Python apps talk to the Soniox REST API and realtime websocket endpoint, so you can focus on building features instead of dealing with boilerplate.

There are two clients:

  • SonioxClient (sync)
  • AsyncSonioxClient (async)

They cover every documented endpoint, realtime support, and additional utils.

Grab your API key from the Soniox Console, wire it into the client, and build the workflow you need.

Install

Packages resides on pypi.

pip install soniox

# or if using uv
uv add soniox

REST API quick start

from soniox import SonioxClient

client = SonioxClient()
transcription = client.transcriptions.transcribe(
    audio_url="https://soniox.com/media/examples/coffee_shop.mp3",
    client_reference_id="docs-quick-start",
)
client.transcriptions.wait(transcription.id, timeout_sec=60)
print(client.transcriptions.get_transcript(transcription.id).text[:200])

The SDK sends auth headers, validates payloads via Pydantic, and raises typed errors (SonioxAPIError, SonioxInvalidRequestError, etc.). Swap to AsyncSonioxClient when you need await semantics.

Realtime API quick start

from soniox import SonioxClient
from soniox.types import RealtimeSTTConfig, Token
from soniox.utils import render_tokens, throttle_audio, start_audio_thread

DEMO_FILE = "path_to_your_audio_file"

client = SonioxClient()
config = RealtimeSTTConfig(model="stt-rt-v3", audio_format="mp3")
final_tokens: list[Token] = []
non_final_tokens: list[Token] = []

def realtime():
    with client.realtime.stt.connect(config=config) as session:
        start_audio_thread(session, throttle_audio(DEMO_FILE, delay_seconds=0.1))
        for event in session.receive_events():
            for token in event.tokens:
                if token.is_final:
                    final_tokens.append(token)
                else:
                    non_final_tokens.append(token)
            print(render_tokens(final_tokens, non_final_tokens))
            non_final_tokens.clear()

realtime()

Realtime helpers manage session lifecycle, control messages, keep-alives, and event parsing so you can show partial transcripts, speakers, and translations as soon as they stream in.

Learn more