The official Python SDK for the Soniox API (STT, REST)
Project description
Soniox Python SDK
The SDK exposes two clients: SonioxClient (sync) and AsyncSonioxClient. Client can hit every Soniox REST endpoint or open a realtime websocket session without wiring headers, retries, or payload validation yourself. Auth, file uploads, transcription polling, webhook helpers, and realtime stream helpers all live in one typed package.
Install
pip install soniox
# or if using uv
uv add soniox
export SONIOX_API_KEY=<your-key>
Get your API key from the Soniox Console and inject it once per shell session. Both clients read SONIOX_API_KEY by default, but you can override it per-client if needed.
Quick run (rest + realtime)
- REST transcription: copy this snippet or run
examples/soniox_client/api_example.py.
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])
- Realtime streaming: the realtime helpers mirror the sync rest sample—open
client.realtime.stt.connect, callsession.send_byte_chunkorsession.send_bytes, then iteratesession.receive_events()to render tokens. example:
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()
see examples/soniox_client/realtime_example.py for the full flow.
Repository layout
src/soniox/– sdk code (clients, http namespaces, realtime/session helpers, types, utils).examples/soniox_client&examples/async_soniox_client– runnable rest + realtime flows for sync and async.docs/– folder wherepydoc-markdowncommand generates full sdk reference markdown file.assets/– sample audio referenced by the examples.tests/– pytest narratives that describe the public behavior.
Development
uv install --with dev
This pulls in ruff, pyright, pytest, pydoc-markdown, etc., so you can lint, type-check, test, and regenerate docs locally.
Resources
- soniox.com/docs – official Soniox documentation.
- GitHub repo – source, examples, and scripts.
- PyPI
- Support:
support@soniox.com.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file soniox-2.0.0.tar.gz.
File metadata
- Download URL: soniox-2.0.0.tar.gz
- Upload date:
- Size: 1.1 MB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
3de226a352566ee357c62d3b24b686e30d988b431a81994151c5407047f23653
|
|
| MD5 |
54484137a283dc8618d9f1dcd1673dc4
|
|
| BLAKE2b-256 |
8e9255f75166850fc96fb275db92352e7c4a05eaf5313258460f64fced43083d
|
File details
Details for the file soniox-2.0.0-py3-none-any.whl.
File metadata
- Download URL: soniox-2.0.0-py3-none-any.whl
- Upload date:
- Size: 35.6 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.8.9
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
e9332de25bb6a0821386e3512a209a267e543429d1a2cd54755bb2efa261b685
|
|
| MD5 |
9335c7cfa03ed885c139c8822ec3f0cf
|
|
| BLAKE2b-256 |
35500afa3f7822e9a5ed1c64c9161fc6e81943b3312676f57485f241618daf64
|