Python SDK
A small, typed-error client for Python 3.9+, built on httpx.
Install
Shell
pip install twentysixConfigure
Python
from twentysix import Client
client = Client(api_key="sk_…", base_url="https://…") # or set TWENTYSIX_API_KEY / TWENTYSIX_BASE_URLClient is a context manager (with Client() as client:) and accepts timeout, max_retries and your own httpx.Client.
Transcribe
Python
# Short audio, one request
result = client.transcribe("note.ogg", "mr-IN", mode="codemix")
# Any length: upload → transcribe → wait → result
result = client.transcribe_file("meeting.m4a", "hi-IN", diarization=True)
print(result["text"])
for s in result["segments"]:
print(s["start"], s.get("speaker"), s["text"])Step by step
Python
upload = client.upload("call.wav") # verified upload with duration_seconds
job = client.create_transcription(upload["id"], "ta-IN", channel_mode="separate",
webhook_endpoint_id="wh_…", idempotency_key="call-8812")
job = client.wait(job["id"]) # polls until completed / partial / failed / cancelled
if job["state"] in ("completed", "partial"):
result = client.result(job["id"])Also: get(id), list(limit, after, state), cancel(id), delete(id), usage(), models(), result(id, format="txt"), and webhook management — create_webhook_endpoint, list_webhook_endpoints, verify_webhook_endpoint, rotate_webhook_secret, disable_webhook_endpoint, list_webhook_deliveries, replay_webhook_delivery.
Files above 50 MB are uploaded resumably in 6 MB chunks and resume after a dropped connection.
Errors
Python
from twentysix import APIError
try:
client.create_transcription(upload["id"], "xx-XX")
except APIError as e:
print(e.status, e.code, e.detail, e.request_id) # 422 unsupported_language language req_…Retries are automatic and never charge twice:
429and503are retried, honouringRetry-After.- A dropped connection or timeout is retried with the same idempotency key (so you get the original transcription, not a second one). Requests that are not safe to repeat, such as registering a webhook endpoint, are not retried.
transcribe()(short audio) acceptsidempotency_key=. Without one, the client creates a key and, after a503, retries with a new key. With your own key, a503is raised to you — resend later with a new key. A504is never retried; usetranscribe_file()for recordings that need longer.- Large uploads resume from the server's offset after a dropped connection.
Webhooks
Python
from twentysix import verify_webhook
ok = verify_webhook(secret, request.headers, raw_body)