Python SDK for the Nexara speech-to-text API: transcription, diarization, speaker roles, structured LLM output
Project description
Nexara Python SDK
Python SDK for the Nexara speech-to-text API: transcription, speaker diarization, speaker role tagging, and structured LLM post-processing. Full API documentation lives at docs.nexara.ru.
Requires Python 3.10+.
pip install nexara
Quickstart
from nexara import Nexara
client = Nexara(api_key="...") # or set NEXARA_API_KEY
text = client.transcriptions.create(file="audio.mp3").text
Pass exactly one of file= (path, bytes, or a binary file object — paths are
streamed from disk, not loaded into memory) or url=.
Diarization
call = client.transcriptions.create(file="call.mp3", task="diarize")
for segment in call.segments:
print(f"{segment.speaker}: {segment.text}")
Add meaningful speaker labels with roles — "auto" lets the model invent
labels, a list restricts them, a dict adds descriptions:
call = client.transcriptions.create(
file="call.mp3",
task="diarize",
roles=["client", "agent"],
)
Long audio: deferred jobs
create_job() submits the audio and returns immediately; the result is fetched
by polling. A failed job is never billed, so resubmitting is free.
job = client.transcriptions.create_job(file="long_recording.mp3")
result = job.wait() # polls; default timeout 1800s
# ...or pick it up later, even from another process:
job = client.transcriptions.retrieve_job(job_id)
Job results live for 12 hours from creation; up to 200 jobs may be in progress
per API key. In this SDK "async" always means asyncio — the deferred mode is
create_job(), not AsyncNexara.
LLM post-processing
Pass prompt= to run an LLM over the transcript, and optionally json_schema=
to force structured output:
result = client.transcriptions.create(
file="meeting.mp3",
prompt="Summarize the key decisions",
json_schema={"type": "object", "properties": {"decisions": {"type": "array"}}},
)
print(result.llm_output) # dict, validated against your schema
print(result.transcription.text) # the transcript it was derived from
asyncio
AsyncNexara is the same interface under await:
from nexara import AsyncNexara
async with AsyncNexara() as client:
result = await client.transcriptions.create(file="audio.mp3")
print(result.text)
Errors and validation
Requests that the server would reject — or, worse, accept, charge for, and
silently do something else with — fail client-side with NexaraValidationError
before any network call. Server errors map to typed exceptions by status code:
from nexara import NexaraValidationError, InsufficientBalanceError, RateLimitError
try:
result = client.transcriptions.create(file="audio.mp3")
except InsufficientBalanceError as e: # 402
print(e.detail)
429 and connection/timeout failures are retried with exponential backoff
(honoring Retry-After). 500 is deliberately not retried: on the
synchronous path the request may already have been billed, so a blind retry
could pay twice. Deferred jobs bill only on success, which makes create_job()
the safe path for retry-heavy workloads.
Not yet available
- Realtime streaming — the protocol is not yet public;
client.realtimeraisesNotImplementedErrorfor now. - Webhooks — job results are fetched by polling.
Development
The package is fully typed (py.typed, mypy strict). Offline tests
(pytest, no network needed) and runnable examples live in the repository;
NEXARA_USE_MOCK=1 runs everything against an in-memory mock transport.
License
MIT
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 nexara-0.1.0.tar.gz.
File metadata
- Download URL: nexara-0.1.0.tar.gz
- Upload date:
- Size: 32.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
4bcf6310f6c304d61b7589774b9a04de429d25544929b74b8837d784329466bf
|
|
| MD5 |
b84af1d587076f2d21670082eb0ea503
|
|
| BLAKE2b-256 |
20fd01ae8d837e92eeb3b153e84f323da2c6d033bbc622e2d71fe1582e3517ab
|
File details
Details for the file nexara-0.1.0-py3-none-any.whl.
File metadata
- Download URL: nexara-0.1.0-py3-none-any.whl
- Upload date:
- Size: 32.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.13
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8bad857463be00624585018b3aa7c265dc685155bb9bcf767061613511a16ae3
|
|
| MD5 |
f53b3374b946ec2adb936ef6165e8591
|
|
| BLAKE2b-256 |
c98e3e1e75801fba64914cfb44d242f2fc70f165cfb90785e641835b79d30867
|