Examples
Step-by-step descriptions of each Python SDK code example.
Each script under examples/ is a runnable story that proves a key surface of the SDK.
Use the links below to open the exact file on GitHub, then run it with a Soniox API key.
Soniox client REST example
examples/soniox_client/api_example.py
- Uploads
assets/coffee_shop.mp3viaclient.files.uploadand records the returned file ID. - Creates a transcription job, polls it to completion with
transcriptions.wait, and prints a transcript snippet. - Handles
SonioxAPIError/SonioxNotFoundError, then deletes both the transcription and uploaded file so you can rerun the example safely.
Sonoix client realtime example
examples/soniox_client/realtime_example.py
- Builds
RealtimeSTTConfig, opensclient.realtime.stt.connect, and streams throttled chunks fromassets/coffee_shop.mp3. - Collects
RealtimeEvent.tokens, splits them into final/non-final buckets, and renders a live transcript view withrender_tokens. - Prints the cached
session.last_messageafter the session closes to show how to inspect the final event.
Async Soniox client REST example
examples/async_soniox_client/api_example.py
- Mirrors the sync REST demo but uses
AsyncSonioxClient,awaitsemantics, and async cleanup in thefinallyblock. - Demonstrates how to list files, trigger a transcription, poll via
await client.transcriptions.wait, and fetch the transcript without blocking the event loop. - Prints structured API error details if something fails so you can wire the same handling into your async app.
Async Soniox client realtime example
examples/async_soniox_client/realtime_example.py
- Opens an async realtime session, streams
throttle_audio_async, and sends control messages implicitly viasend_bytes. - Iterates
async for event in session.receive_events()so tokens arrive as they are produced. - Uses
render_tokensto show speaker-aware snippets, then printssession.last_messageafter theasync withblock.
Each example writes to stdout so you can follow the story while the script runs.