OtherSDKsPythonFull SDK reference

Async Client

Soniox Python SDK - Async Client Reference


Sync mirror: the synchronous SonioxClient exposes the same API as AsyncSonioxClient below - drop await from each call and treat AsyncIterator[X] return types as plain Iterator[X]. Only the async surface is documented here to avoid duplicating an otherwise identical reference. Realtime sessions have genuinely different sync/async patterns and are documented in the Realtime Client page.


AsyncSonioxClient

Asynchronous Soniox REST client exposing HTTP and realtime helpers.

Constructor

AsyncSonioxClient(api_key: str | None = None, api_base_url: str | None = None, websocket_base_url: str | None = None, tts_api_base_url: str | None = None, tts_websocket_base_url: str | None = None, timeout_sec: float | None = None, webhook_secret: str | None = None, webhook_signature_header: str | None = None, **client_kwargs: Any)

Parameters

ParameterTypeDescription
api_keystr | NoneAPI key used for authentication.
api_base_urlstr | NoneBase URL for Soniox REST API requests.
websocket_base_urlstr | NoneBase URL for Soniox realtime WebSocket endpoint.
tts_api_base_urlstr | NoneBase URL for Soniox Text-to-Speech REST API requests.
tts_websocket_base_urlstr | NoneBase URL for Soniox Text-to-Speech realtime WebSocket endpoint.
timeout_secfloat | NoneMaximum wait time in seconds.
webhook_secretstr | NoneWebhook secret used for signature verification.
webhook_signature_headerstr | NoneWebhook signature header name.
client_kwargsAnyAdditional HTTP client keyword arguments.

Returns

None

Properties

PropertyTypeDescription
filesAsyncFilesAPIFile upload and management API namespace.
sttAsyncSttAPISpeech-to-text API namespace.
ttsAsyncTtsAPIText-to-Speech API namespace.
modelsAsyncModelsAPISpeech-to-text model listing API namespace.
tts_modelsAsyncTtsModelsAPIText-to-Speech model listing API namespace.
voicesAsyncVoicesAPIVoice cloning, shared voice listing and voice management API namespace.
usage_logsAsyncUsageLogsAPIPer-request usage log API namespace.
usageAsyncUsageAPIUsage and cost summary API namespace.
concurrency_limitsAsyncConcurrencyLimitsAPIConcurrency limit API namespace.
authAsyncAuthAPIAuthentication API namespace.
webhooksAsyncSonioxWebhooksAPIWebhook utilities API namespace.
realtimeAsyncRealtimeAPIRealtime websocket API namespace (STT and TTS).

request()

request(method: str, path: str, *, params: Mapping[str, Any] | None = None, json: Any | None = None, data: Mapping[str, Any] | None = None, files: Mapping[str, Any] | None = None) -> httpx.Response

Perform a request against the configured Soniox REST endpoint.

Parameters

ParameterTypeDescription
methodstrHTTP method to use for the request.
pathstrRelative API path for the request.
paramsMapping[str, Any] | NoneQuery parameters for the request.
jsonAny | NoneJSON request payload.
dataMapping[str, Any] | NoneForm-encoded request payload.
filesMapping[str, Any] | NoneMultipart file payload mapping.

Returns

httpx.Response


aclose()

aclose() -> None

Close any outstanding async HTTP connections.

Returns

None


AsyncFilesAPI

Constructor

AsyncFilesAPI(client: AsyncSonioxClient)

Parameters

ParameterTypeDescription
clientAsyncSonioxClientSoniox client instance.

Returns

None

list()

list(limit: int = 100, cursor: str | None = None) -> GetFilesResponse

List uploaded files.

Performs a GET request to /files with optional pagination.

Parameters

ParameterTypeDescription
limitintMaximum number of files to return.
cursorstr | NonePagination cursor for the next page of results.

Returns

GetFilesResponse

Raises

  • SonioxAPIError When the API returns an error.

count()

count() -> GetFilesCountResponse

Return a breakdown of uploaded file counts.

Performs a GET request to /files/count.

Returns

GetFilesCountResponse

Raises

  • SonioxAPIError When the API returns an error.

list_all()

list_all(limit: int = 100) -> AsyncGenerator[File, None]

Iterate through all uploaded files across all pages.

Parameters

ParameterTypeDescription
limitintMaximum number of files to return.

Yields

AsyncGenerator[File, None]

File: The next file object from the API.

Raises

  • SonioxAPIError When the API returns an error.

get()

get(file_id: str) -> File

Retrieve a file by ID.

Performs a GET request to /files/{file_id}.

Parameters

ParameterTypeDescription
file_idstrID of a previously uploaded file.

Returns

File

Raises

  • SonioxAPIError When the API returns an error.

get_or_none()

get_or_none(file_id: str) -> File | None

Retrieve a file by ID.

Returns None if the file does not exist.

Parameters

ParameterTypeDescription
file_idstrID of a previously uploaded file.

Returns

File | None

Raises

  • SonioxAPIError When the API returns an error.

delete()

delete(file_id: str) -> None

Delete a file by ID.

Performs a DELETE request to /files/{file_id}.

Parameters

ParameterTypeDescription
file_idstrID of a previously uploaded file.

Returns

None

Raises

  • SonioxAPIError When the API returns an error.

delete_if_exists()

delete_if_exists(file_id: str) -> None

Delete a file by ID if it exists.

Ignores missing files.

Parameters

ParameterTypeDescription
file_idstrID of a previously uploaded file.

Returns

None

Raises

  • SonioxAPIError When the API returns an error.

upload()

upload(file: BinaryIO | bytes | Path | str, *, filename: str | None = None, client_reference_id: str | None = None) -> File

Upload a file.

Performs a multipart POST request to /files.

Uploaded files are automatically deleted 30 days after upload.

Parameters

ParameterTypeDescription
fileBinaryIO | bytes | Path | strFile input to upload or transcribe.
filenamestr | NoneFilename associated with uploaded file data.
client_reference_idstr | NoneOptional tracking identifier string. Does not need to be unique

Returns

File

Raises

  • SonioxAPIError When the API returns an error.

delete_all()

delete_all(limit: int = 100) -> None

Delete all files.

Iterates through all pages and deletes each file. Stops and raises on the first failed deletion.

Parameters

ParameterTypeDescription
limitintMaximum number of files to return.

Returns

None

Raises

  • SonioxAPIError When the API returns an error.

AsyncSttAPI

Constructor

AsyncSttAPI(client: AsyncSonioxClient)

Parameters

ParameterTypeDescription
clientAsyncSonioxClientSoniox client instance.

Returns

None

list()

list(limit: int = 100, cursor: str | None = None) -> GetTranscriptionsResponse

List transcriptions.

Performs a GET request to /transcriptions with optional pagination.

Parameters

ParameterTypeDescription
limitintMaximum number of transcriptions to return.
cursorstr | NonePagination cursor for the next page of results.

Returns

GetTranscriptionsResponse

Raises

  • SonioxAPIError When the API returns an error.

count()

count() -> GetTranscriptionsCountResponse

Return a breakdown of transcription counts.

Performs a GET request to /transcriptions/count.

Returns

GetTranscriptionsCountResponse

Raises

  • SonioxAPIError When the API returns an error.

list_all()

list_all(limit: int = 100) -> AsyncGenerator[Transcription, None]

Iterate through all transcriptions across all pages.

Parameters

ParameterTypeDescription
limitintMaximum number of transcriptions to return.

Yields

AsyncGenerator[Transcription, None]

File: The next transcription object from the API.

Raises

  • SonioxAPIError When the API returns an error.

delete_all()

delete_all(limit: int = 100) -> None

Delete all transcriptions.

Iterates through all pages and deletes each transcription. Stops and raises on the first failed deletion.

Parameters

ParameterTypeDescription
limitintMaximum number of transcriptions to return.

Returns

None

Raises

  • SonioxAPIError When the API returns an error.

create()

create(*, model: str = DEFAULT_MODEL, file_id: str | None = None, audio_url: str | None = None, client_reference_id: str | None = None, config: CreateTranscriptionConfig | None = None) -> Transcription

Create a transcription.

Performs a POST request to /transcriptions.

Transcriptions are automatically deleted 30 days after creation.

Parameters

ParameterTypeDescription
modelstrSpeech-to-text model to use.
file_idstr | NoneID of a previously uploaded file.
audio_urlstr | NonePublicly accessible audio URL.
client_reference_idstr | NoneOptional tracking identifier.
configCreateTranscriptionConfig | NoneConfiguration options for this operation.

Returns

Transcription

Raises

  • SonioxAPIError When the API returns an error.

get()

get(transcription_id: str) -> Transcription

Retrieve a transcription by ID.

Performs a GET request to /transcriptions/{transcription_id}.

Parameters

ParameterTypeDescription
transcription_idstrTranscription identifier.

Returns

Transcription

Raises

  • SonioxAPIError When the API returns an error.

get_or_none()

get_or_none(transcription_id: str) -> Transcription | None

Retrieve a transcription by ID.

Returns None if the transcription does not exist.

Parameters

ParameterTypeDescription
transcription_idstrTranscription identifier.

Returns

Transcription | None

Raises

  • SonioxAPIError When the API returns an error.

delete()

delete(transcription_id: str) -> None

Delete a transcription by ID.

Performs a DELETE request to /transcriptions/{transcription_id}.

Parameters

ParameterTypeDescription
transcription_idstrTranscription identifier.

Returns

None

Raises

  • SonioxAPIError When the API returns an error.

delete_if_exists()

delete_if_exists(transcription_id: str) -> None

Delete a transcription by ID if it exists.

Ignores missing transcriptions.

Parameters

ParameterTypeDescription
transcription_idstrTranscription identifier.

Returns

None

Raises

  • SonioxAPIError When the API returns an error.

destroy()

destroy(transcription_id: str) -> None

Delete a transcription and its associated uploaded file.

Parameters

ParameterTypeDescription
transcription_idstrTranscription identifier.

Returns

None

Raises

  • SonioxAPIError When the API returns an error.

destroy_all()

destroy_all(limit: int = 100) -> None

Delete all transcriptions and their associated files. Stops and raises on the first failed deletion.

Parameters

ParameterTypeDescription
limitintMaximum number of transcriptions to return.

Returns

None

Raises

  • SonioxAPIError When the API returns an error during listing.

get_transcript()

get_transcript(transcription_id: str) -> TranscriptionTranscript

Retrieve the transcript for a transcription.

Performs a GET request to /transcriptions/{transcription_id}/transcript.

Parameters

ParameterTypeDescription
transcription_idstrTranscription identifier.

Returns

TranscriptionTranscript

Raises

  • SonioxAPIError When the API returns an error.

wait()

wait(transcription_id: str, *, interval_sec: float = 5.0, timeout_sec: float | None = None) -> Transcription

Poll a transcription until it leaves the queued or processing state.

Parameters

ParameterTypeDescription
transcription_idstrTranscription identifier.
interval_secfloatPolling interval in seconds.
timeout_secfloat | NoneMaximum wait time in seconds.

Returns

Transcription

Raises

  • SonioxAPIError When the API returns an error.
  • TimeoutError Waiting for the transcription to finish exceeded timeout_sec.

transcribe_from_url()

transcribe_from_url(*, model: str = DEFAULT_MODEL, audio_url: str, client_reference_id: str | None = None, config: CreateTranscriptionConfig | None = None) -> Transcription

Create a transcription from an audio URL.

Parameters

ParameterTypeDescription
modelstrSpeech-to-text model to use.
audio_urlstrPublicly accessible audio URL.
client_reference_idstr | NoneOptional tracking identifier.
configCreateTranscriptionConfig | NoneConfiguration options for this operation.

Returns

Transcription

Raises

  • SonioxAPIError When the API returns an error.

transcribe_from_file_id()

transcribe_from_file_id(*, model: str = DEFAULT_MODEL, file_id: str, client_reference_id: str | None = None, config: CreateTranscriptionConfig | None = None) -> Transcription

Create a transcription from an existing uploaded file.

Parameters

ParameterTypeDescription
modelstrSpeech-to-text model to use.
file_idstrID of a previously uploaded file.
client_reference_idstr | NoneOptional tracking identifier.
configCreateTranscriptionConfig | NoneConfiguration options for this operation.

Returns

Transcription

Raises

  • SonioxAPIError When the API returns an error.

transcribe_from_file()

transcribe_from_file(*, model: str = DEFAULT_MODEL, file: BinaryIO | bytes | Path | str, filename: str | None = None, client_reference_id: str | None = None, config: CreateTranscriptionConfig | None = None) -> Transcription

Upload a file and create a transcription from it.

Parameters

ParameterTypeDescription
modelstrSpeech-to-text model to use.
fileBinaryIO | bytes | Path | strFile input to upload or transcribe.
filenamestr | NoneFilename associated with uploaded file data.
client_reference_idstr | NoneOptional tracking identifier.
configCreateTranscriptionConfig | NoneConfiguration options for this operation.

Returns

Transcription

Raises

  • SonioxAPIError When the API returns an error.

transcribe()

transcribe(*, model: str = DEFAULT_MODEL, audio_url: str | None = None, file_id: str | None = None, file: BinaryIO | bytes | Path | str | None = None, filename: str | None = None, client_reference_id: str | None = None, config: CreateTranscriptionConfig | None = None) -> Transcription

Create a transcription from a file, file ID, or audio URL.

Validates mutually exclusive inputs before submission.

Parameters

ParameterTypeDescription
modelstrSpeech-to-text model to use.
audio_urlstr | NonePublicly accessible audio URL.
file_idstr | NoneID of a previously uploaded file.
fileBinaryIO | bytes | Path | str | NoneFile input to upload or transcribe.
filenamestr | NoneFilename associated with uploaded file data.
client_reference_idstr | NoneOptional tracking identifier.
configCreateTranscriptionConfig | NoneConfiguration options for this operation.

Returns

Transcription

Raises

  • SonioxAPIError When the API returns an error.
  • SonioxValidationError When the payload fails validation.

transcribe_file_with_webhook()

transcribe_file_with_webhook(*, model: str = DEFAULT_MODEL, file: BinaryIO | bytes | Path | str, webhook_url: str, filename: str | None = None, client_reference_id: str | None = None, webhook_auth: WebhookAuthConfig | None = None, config: CreateTranscriptionConfig | None = None) -> Transcription

Upload a file, configure a webhook, and start transcription.

Parameters

ParameterTypeDescription
modelstrSpeech-to-text model to use.
fileBinaryIO | bytes | Path | strFile input to upload or transcribe.
webhook_urlstrURL to receive webhook notifications.
filenamestr | NoneFilename associated with uploaded file data.
client_reference_idstr | NoneOptional tracking identifier.
webhook_authWebhookAuthConfig | NoneWebhook authentication configuration.
configCreateTranscriptionConfig | NoneConfiguration options for this operation.

Returns

Transcription

Raises

  • SonioxAPIError When the API returns an error.

transcribe_and_wait()

transcribe_and_wait(*, model: str = DEFAULT_MODEL, audio_url: str | None = None, file_id: str | None = None, file: BinaryIO | bytes | Path | str | None = None, filename: str | None = None, client_reference_id: str | None = None, delete_after: bool = False, wait_interval_sec: float = 5.0, wait_timeout_sec: float | None = None, config: CreateTranscriptionConfig | None = None) -> Transcription

Create a transcription and wait for completion.

Returns a Transcription object after it is completed. Optionally deletes the transcription and the uploaded file after completion.

Parameters

ParameterTypeDescription
modelstrSpeech-to-text model to use.
audio_urlstr | NonePublicly accessible audio URL.
file_idstr | NoneID of a previously uploaded file.
fileBinaryIO | bytes | Path | str | NoneFile input to upload or transcribe.
filenamestr | NoneFilename associated with uploaded file data.
client_reference_idstr | NoneOptional tracking identifier.
delete_afterboolWhether to delete created resources after completion.
wait_interval_secfloatPolling interval in seconds while waiting.
wait_timeout_secfloat | NoneMaximum wait time in seconds while polling.
configCreateTranscriptionConfig | NoneConfiguration options for this operation.

Returns

Transcription

Raises

  • SonioxAPIError When the API returns an error.
  • SonioxValidationError When the payload fails validation.
  • TimeoutError Waiting for the transcription to finish exceeded timeout_sec.

transcribe_and_wait_with_tokens()

transcribe_and_wait_with_tokens(*, model: str = DEFAULT_MODEL, audio_url: str | None = None, file_id: str | None = None, file: BinaryIO | bytes | Path | str | None = None, filename: str | None = None, client_reference_id: str | None = None, delete_after: bool = False, wait_interval_sec: float = 5.0, wait_timeout_sec: float | None = None, config: CreateTranscriptionConfig | None = None) -> TranscriptionTranscript

Create a transcription, wait for completion, and return the transcript.

Optionally deletes the transcription and uploaded file after completion.

Parameters

ParameterTypeDescription
modelstrSpeech-to-text model to use.
audio_urlstr | NonePublicly accessible audio URL.
file_idstr | NoneID of a previously uploaded file.
fileBinaryIO | bytes | Path | str | NoneFile input to upload or transcribe.
filenamestr | NoneFilename associated with uploaded file data.
client_reference_idstr | NoneOptional tracking identifier.
delete_afterboolWhether to delete created resources after completion.
wait_interval_secfloatPolling interval in seconds while waiting.
wait_timeout_secfloat | NoneMaximum wait time in seconds while polling.
configCreateTranscriptionConfig | NoneConfiguration options for this operation.

Returns

TranscriptionTranscript

Raises

  • SonioxAPIError When the API returns an error.
  • SonioxValidationError When the payload fails validation.
  • TimeoutError Waiting for the transcription to finish exceeded timeout_sec.

translate_from_url()

translate_from_url(*, audio_url: str, to: LanguageCode | None = None, source: LanguageCode | None = None, between: tuple[LanguageCode, LanguageCode] | None = None, model: str = DEFAULT_MODEL, client_reference_id: str | None = None, config: CreateTranscriptionConfig | None = None) -> Transcription

Translate audio at a URL.

Provide exactly one of to (one-way) or between (two-way). source is an optional language hint and is only valid with to.

Parameters

ParameterTypeDescription
audio_urlstrPublicly accessible audio URL.
toLanguageCode | None-
sourceLanguageCode | NoneThe source term to translate.
betweentuple[LanguageCode, LanguageCode] | None-
modelstrSpeech-to-text model to use.
client_reference_idstr | NoneOptional tracking identifier.
configCreateTranscriptionConfig | NoneConfiguration options for this operation.

Returns

Transcription

Raises

  • SonioxAPIError When the API returns an error.
  • SonioxValidationError When the translate kwargs are invalid.

translate_from_file_id()

translate_from_file_id(*, file_id: str, to: LanguageCode | None = None, source: LanguageCode | None = None, between: tuple[LanguageCode, LanguageCode] | None = None, model: str = DEFAULT_MODEL, client_reference_id: str | None = None, config: CreateTranscriptionConfig | None = None) -> Transcription

Translate an already-uploaded file.

Provide exactly one of to (one-way) or between (two-way). source is an optional language hint and is only valid with to.

Parameters

ParameterTypeDescription
file_idstrID of a previously uploaded file.
toLanguageCode | None-
sourceLanguageCode | NoneThe source term to translate.
betweentuple[LanguageCode, LanguageCode] | None-
modelstrSpeech-to-text model to use.
client_reference_idstr | NoneOptional tracking identifier.
configCreateTranscriptionConfig | NoneConfiguration options for this operation.

Returns

Transcription

Raises

  • SonioxAPIError When the API returns an error.
  • SonioxValidationError When the translate kwargs are invalid.

translate_from_file()

translate_from_file(*, file: BinaryIO | bytes | Path | str, to: LanguageCode | None = None, source: LanguageCode | None = None, between: tuple[LanguageCode, LanguageCode] | None = None, filename: str | None = None, model: str = DEFAULT_MODEL, client_reference_id: str | None = None, config: CreateTranscriptionConfig | None = None) -> Transcription

Upload a file and translate it.

Provide exactly one of to (one-way) or between (two-way). source is an optional language hint and is only valid with to.

Parameters

ParameterTypeDescription
fileBinaryIO | bytes | Path | strFile input to upload or transcribe.
toLanguageCode | None-
sourceLanguageCode | NoneThe source term to translate.
betweentuple[LanguageCode, LanguageCode] | None-
filenamestr | NoneFilename associated with uploaded file data.
modelstrSpeech-to-text model to use.
client_reference_idstr | NoneOptional tracking identifier.
configCreateTranscriptionConfig | NoneConfiguration options for this operation.

Returns

Transcription

Raises

  • SonioxAPIError When the API returns an error.
  • SonioxValidationError When the translate kwargs are invalid.

translate()

translate(*, to: LanguageCode | None = None, source: LanguageCode | None = None, between: tuple[LanguageCode, LanguageCode] | None = None, audio_url: str | None = None, file_id: str | None = None, file: BinaryIO | bytes | Path | str | None = None, filename: str | None = None, model: str = DEFAULT_MODEL, client_reference_id: str | None = None, config: CreateTranscriptionConfig | None = None) -> Transcription

Translate audio from a file, file ID, or URL.

Provide exactly one of to (one-way) or between (two-way). source is an optional language hint and is only valid with to. Convenience over transcribe() that fills in the translation config and forces enable_language_identification=True.

Parameters

ParameterTypeDescription
toLanguageCode | None-
sourceLanguageCode | NoneThe source term to translate.
betweentuple[LanguageCode, LanguageCode] | None-
audio_urlstr | NonePublicly accessible audio URL.
file_idstr | NoneID of a previously uploaded file.
fileBinaryIO | bytes | Path | str | NoneFile input to upload or transcribe.
filenamestr | NoneFilename associated with uploaded file data.
modelstrSpeech-to-text model to use.
client_reference_idstr | NoneOptional tracking identifier.
configCreateTranscriptionConfig | NoneConfiguration options for this operation.

Returns

Transcription

Raises

  • SonioxAPIError When the API returns an error.
  • SonioxValidationError When the payload or translate kwargs are invalid.

translate_and_wait()

translate_and_wait(*, to: LanguageCode | None = None, source: LanguageCode | None = None, between: tuple[LanguageCode, LanguageCode] | None = None, audio_url: str | None = None, file_id: str | None = None, file: BinaryIO | bytes | Path | str | None = None, filename: str | None = None, model: str = DEFAULT_MODEL, client_reference_id: str | None = None, delete_after: bool = False, wait_interval_sec: float = 5.0, wait_timeout_sec: float | None = None, config: CreateTranscriptionConfig | None = None) -> Transcription

Translate and wait for completion. Returns the finished Transcription.

Provide exactly one of to (one-way) or between (two-way). source is an optional language hint and is only valid with to.

Parameters

ParameterTypeDescription
toLanguageCode | None-
sourceLanguageCode | NoneThe source term to translate.
betweentuple[LanguageCode, LanguageCode] | None-
audio_urlstr | NonePublicly accessible audio URL.
file_idstr | NoneID of a previously uploaded file.
fileBinaryIO | bytes | Path | str | NoneFile input to upload or transcribe.
filenamestr | NoneFilename associated with uploaded file data.
modelstrSpeech-to-text model to use.
client_reference_idstr | NoneOptional tracking identifier.
delete_afterboolWhether to delete created resources after completion.
wait_interval_secfloatPolling interval in seconds while waiting.
wait_timeout_secfloat | NoneMaximum wait time in seconds while polling.
configCreateTranscriptionConfig | NoneConfiguration options for this operation.

Returns

Transcription

Raises

  • SonioxAPIError When the API returns an error.
  • SonioxValidationError When the payload or translate kwargs are invalid.
  • TimeoutError Waiting for the transcription to finish exceeded wait_timeout_sec.

translate_and_wait_with_tokens()

translate_and_wait_with_tokens(*, to: LanguageCode | None = None, source: LanguageCode | None = None, between: tuple[LanguageCode, LanguageCode] | None = None, audio_url: str | None = None, file_id: str | None = None, file: BinaryIO | bytes | Path | str | None = None, filename: str | None = None, model: str = DEFAULT_MODEL, client_reference_id: str | None = None, delete_after: bool = False, wait_interval_sec: float = 5.0, wait_timeout_sec: float | None = None, config: CreateTranscriptionConfig | None = None) -> TranscriptionTranscript

Translate, wait for completion, and return the transcript with tokens.

Provide exactly one of to (one-way) or between (two-way). source is an optional language hint and is only valid with to. Optionally deletes the transcription and uploaded file after completion.

Parameters

ParameterTypeDescription
toLanguageCode | None-
sourceLanguageCode | NoneThe source term to translate.
betweentuple[LanguageCode, LanguageCode] | None-
audio_urlstr | NonePublicly accessible audio URL.
file_idstr | NoneID of a previously uploaded file.
fileBinaryIO | bytes | Path | str | NoneFile input to upload or transcribe.
filenamestr | NoneFilename associated with uploaded file data.
modelstrSpeech-to-text model to use.
client_reference_idstr | NoneOptional tracking identifier.
delete_afterboolWhether to delete created resources after completion.
wait_interval_secfloatPolling interval in seconds while waiting.
wait_timeout_secfloat | NoneMaximum wait time in seconds while polling.
configCreateTranscriptionConfig | NoneConfiguration options for this operation.

Returns

TranscriptionTranscript

Raises

  • SonioxAPIError When the API returns an error.
  • SonioxValidationError When the payload or translate kwargs are invalid.
  • TimeoutError Waiting for the transcription to finish exceeded wait_timeout_sec.

AsyncTtsAPI

Constructor

AsyncTtsAPI(client: AsyncSonioxClient)

Parameters

ParameterTypeDescription
clientAsyncSonioxClientSoniox client instance.

Returns

None

generate()

generate(*, text: str, voice: str, model: str = DEFAULT_MODEL, config: CreateTtsConfig | None = None, language: str | None = None, audio_format: TtsAudioFormat | None = None, sample_rate: TtsSampleRate | None = None, bitrate: TtsBitrate | None = None) -> bytes

Generate speech audio from text and return raw audio bytes.

Performs a POST request to the TTS REST endpoint.

audio_format/sample_rate/bitrate are deprecated; set them on CreateTtsConfig instead. Pass language explicitly — relying on the default ("en") is deprecated and language will be required in the next major release.

Parameters

ParameterTypeDescription
textstrLonger free-form background text, prior interaction history, reference documents, or meeting notes.
voicestrVoice identifier to generate speech audio with.
modelstrSpeech-to-text model to use.
configCreateTtsConfig | NoneConfiguration options for this operation.
languagestr | NoneLanguage code for Text-to-Speech (e.g., "en").
audio_formatTtsAudioFormat | NoneAudio format for realtime transcription.
sample_rateTtsSampleRate | NoneAudio sample rate in Hz.
bitrateTtsBitrate | NoneOutput bitrate in bits-per-second for compressed formats.

Returns

bytes

Raises

  • SonioxAPIError When the API returns an error.

generate_to_file()

generate_to_file(output: BinaryIO | Path | str, *, text: str, voice: str = DEFAULT_VOICE, model: str = DEFAULT_MODEL, config: CreateTtsConfig | None = None, language: str | None = None, audio_format: TtsAudioFormat | None = None, sample_rate: TtsSampleRate | None = None, bitrate: TtsBitrate | None = None) -> int

Generate speech audio from text and write the audio bytes to a file-like output.

audio_format/sample_rate/bitrate are deprecated; set them on CreateTtsConfig instead. Pass language explicitly — relying on the default ("en") is deprecated and language will be required in the next major release.

Parameters

ParameterTypeDescription
outputBinaryIO | Path | str-
textstrLonger free-form background text, prior interaction history, reference documents, or meeting notes.
voicestrVoice identifier to generate speech audio with.
modelstrSpeech-to-text model to use.
configCreateTtsConfig | NoneConfiguration options for this operation.
languagestr | NoneLanguage code for Text-to-Speech (e.g., "en").
audio_formatTtsAudioFormat | NoneAudio format for realtime transcription.
sample_rateTtsSampleRate | NoneAudio sample rate in Hz.
bitrateTtsBitrate | NoneOutput bitrate in bits-per-second for compressed formats.

Returns

int

Number of bytes written.


AsyncTtsModelsAPI

Constructor

AsyncTtsModelsAPI(client: AsyncSonioxClient)

Parameters

ParameterTypeDescription
clientAsyncSonioxClientSoniox client instance.

Returns

None

list()

list() -> GetTtsModelsResponse

List available Text-to-Speech models.

Performs a GET request to /tts-models.

Returns

GetTtsModelsResponse

Raises

  • SonioxAPIError When the API returns an error.

AsyncVoicesAPI

Constructor

AsyncVoicesAPI(client: AsyncSonioxClient)

Parameters

ParameterTypeDescription
clientAsyncSonioxClientSoniox client instance.

Returns

None

list()

list(limit: int = 100, cursor: str | None = None) -> GetVoicesResponse

List the voices you cloned in the project.

For the built-in voices of a model, use list_shared().

Performs a GET request to /voices with optional pagination.

Parameters

ParameterTypeDescription
limitintMaximum number of voices to return.
cursorstr | NonePagination cursor for the next page of results.

Returns

GetVoicesResponse

Raises

  • SonioxAPIError When the API returns an error.

count()

count() -> GetVoicesCountResponse

Return the total number of voices in the project.

Performs a GET request to /voices/count.

Returns

GetVoicesCountResponse

Raises

  • SonioxAPIError When the API returns an error.

list_all()

list_all(limit: int = 100) -> AsyncGenerator[Voice, None]

Iterate through all cloned voices across all pages.

For the built-in voices of a model, use list_all_shared().

Parameters

ParameterTypeDescription
limitintMaximum number of voices to return.

Yields

AsyncGenerator[Voice, None]

Voice: The next voice object from the API.

Raises

  • SonioxAPIError When the API returns an error.

list_shared()

list_shared(model: str, *, gender: TtsVoiceGender | None = None, age: TtsVoiceAge | None = None, accent: str | None = None, use_case: list[str] | None = None, style: list[str] | None = None, limit: int = 100, cursor: str | None = None) -> GetSharedVoicesResponse

List the shared voices built into a Text-to-Speech model.

Performs a GET request to /shared-voices. All given filters must match. For voices you cloned yourself, use list().

Parameters

ParameterTypeDescription
modelstrId of the TTS model whose voices to return.
genderTtsVoiceGender | NoneOnly return voices of this gender.
ageTtsVoiceAge | NoneOnly return voices of this age.
accentstr | NoneOnly return voices with this accent.
use_caselist[str] | NoneOnly return voices tagged with every listed use case.
stylelist[str] | NoneOnly return voices tagged with every listed style.
limitintMaximum number of voices to return (1-200).
cursorstr | NonePagination cursor. Pass the same filters alongside it; the cursor points into the filtered list, not the whole catalogue.

Returns

GetSharedVoicesResponse

Raises

  • SonioxAPIError When the API returns an error.

list_all_shared()

list_all_shared(model: str, *, gender: TtsVoiceGender | None = None, age: TtsVoiceAge | None = None, accent: str | None = None, use_case: list[str] | None = None, style: list[str] | None = None, limit: int = 100) -> AsyncGenerator[TtsVoiceDetails, None]

Iterate through all shared voices of a Text-to-Speech model across all pages.

Accepts the same filters as list_shared(); they are sent with every page.

Parameters

ParameterTypeDescription
modelstrId of the TTS model whose voices to return.
genderTtsVoiceGender | NoneOnly return voices of this gender.
ageTtsVoiceAge | NoneOnly return voices of this age.
accentstr | NoneOnly return voices with this accent.
use_caselist[str] | NoneOnly return voices tagged with every listed use case.
stylelist[str] | NoneOnly return voices tagged with every listed style.
limitintMaximum number of voices to return.

Yields

AsyncGenerator[TtsVoiceDetails, None]

TtsVoiceDetails: The next voice matching the filters.

Raises

  • SonioxAPIError When the API returns an error.

get()

get(voice_id: str) -> Voice

Retrieve a voice by ID.

Performs a GET request to /voices/{voice_id}.

Parameters

ParameterTypeDescription
voice_idstrVoice identifier.

Returns

Voice

Raises

  • SonioxAPIError When the API returns an error.

get_or_none()

get_or_none(voice_id: str) -> Voice | None

Retrieve a voice by ID.

Returns None if the voice does not exist.

Parameters

ParameterTypeDescription
voice_idstrVoice identifier.

Returns

Voice | None

Raises

  • SonioxAPIError When the API returns an error.

create()

create(file: BinaryIO | bytes | Path | str, *, name: str, filename: str | None = None) -> Voice

Create a cloned voice from a reference audio clip.

Performs a multipart POST request to /voices.

Parameters

ParameterTypeDescription
fileBinaryIO | bytes | Path | strFile input to upload or transcribe.
namestrName of the model.
filenamestr | NoneFilename associated with uploaded file data.

Returns

Voice

Raises

  • SonioxAPIError When the API returns an error.

recompute()

recompute(voice_id: str, *, model: str | None = None) -> Voice

Prepare an existing voice for models it is not ready for yet.

Performs a POST request to /voices/{voice_id}/recompute. When model is omitted, the voice is prepared for every available model it is not ready for; models it is already prepared for are left unchanged.

Parameters

ParameterTypeDescription
voice_idstrVoice identifier.
modelstr | NoneModel to prepare the voice for. If None, prepares it for every not-yet-ready model.

Returns

Voice

Raises

  • SonioxAPIError When the API returns an error.

delete()

delete(voice_id: str) -> None

Delete a voice by ID.

Performs a DELETE request to /voices/{voice_id}.

Parameters

ParameterTypeDescription
voice_idstrVoice identifier.

Returns

None

Raises

  • SonioxAPIError When the API returns an error.

delete_if_exists()

delete_if_exists(voice_id: str) -> None

Delete a voice by ID if it exists.

Ignores missing voices.

Parameters

ParameterTypeDescription
voice_idstrVoice identifier.

Returns

None

Raises

  • SonioxAPIError When the API returns an error.

AsyncModelsAPI

Constructor

AsyncModelsAPI(client: AsyncSonioxClient)

Parameters

ParameterTypeDescription
clientAsyncSonioxClientSoniox client instance.

Returns

None

list()

list() -> GetModelsResponse

List available models.

Performs a GET request to /models.

Returns

GetModelsResponse

Raises

  • SonioxAPIError When the API returns an error.

AsyncUsageLogsAPI

Constructor

AsyncUsageLogsAPI(client: AsyncSonioxClient)

Parameters

ParameterTypeDescription
clientAsyncSonioxClientSoniox client instance.

Returns

None

list()

list(start_time: str, end_time: str, limit: int = 1000, sort: UsageLogsSort = 'end_time_asc', cursor: str | None = None) -> GetUsageLogsResponse

List usage-log entries for a time window.

Performs a GET request to /usage-logs.

Parameters

ParameterTypeDescription
start_timestrStart of the window (inclusive). Filters by request end time.
end_timestrEnd of the window (exclusive). Filters by request end time.
limitintMaximum number of entries to return (1–1000).
sortUsageLogsSortSort order by end_time.
cursorstr | NonePagination cursor for the next page.

Returns

GetUsageLogsResponse

Raises

  • SonioxAPIError When the API returns an error.

list_all()

list_all(start_time: str, end_time: str, limit: int = 1000, sort: UsageLogsSort = 'end_time_asc') -> AsyncGenerator[UsageLogEntry, None]

Iterate through all usage-log entries across all pages.

Parameters

ParameterTypeDescription
start_timestrStart of the window (inclusive). Filters by request end time.
end_timestrEnd of the window (exclusive). Filters by request end time.
limitintMaximum number of entries to return (1–1000).
sortUsageLogsSortSort order by end_time.

Returns

AsyncGenerator[UsageLogEntry, None]


AsyncUsageAPI

Constructor

AsyncUsageAPI(client: AsyncSonioxClient)

Parameters

ParameterTypeDescription
clientAsyncSonioxClientSoniox client instance.

Returns

None

summary()

summary(start_time: str, end_time: str) -> GetUsageSummaryResponse

Return daily cost and activity for the project, per model and in total.

Performs a GET request to /usage/summary.

Parameters

ParameterTypeDescription
start_timestrStart of the window (inclusive), ISO 8601 UTC.
end_timestrEnd of the window (exclusive), ISO 8601 UTC. A UTC day is included when the window covers any part of it, so an end_time at exactly midnight leaves out its own day. At most 366 days.

Returns

GetUsageSummaryResponse

Raises

  • SonioxAPIError When the API returns an error.

AsyncConcurrencyLimitsAPI

Constructor

AsyncConcurrencyLimitsAPI(client: AsyncSonioxClient)

Parameters

ParameterTypeDescription
clientAsyncSonioxClientSoniox client instance.

Returns

None

get()

get() -> GetConcurrencyLimitsResponse

Get current concurrent sessions and configured limits.

Performs a GET request to /concurrency-limits.

Returns

GetConcurrencyLimitsResponse

Project- and organization-scoped current counts and configured limits for realtime STT and TTS sessions.

Raises

  • SonioxAPIError When the API returns an error.

history()

history(start_time: str, end_time: str, *, period_sec: ConcurrentStreamsPeriodSec, kind: ConcurrentStreamKind) -> GetConcurrentStreamsHistoryResponse

Get historical concurrent stream counts, aggregated per period.

Performs a GET request to /concurrent-streams-history.

Parameters

ParameterTypeDescription
start_timestrStart of the window (inclusive), ISO 8601 UTC.
end_timestrEnd of the window (exclusive), ISO 8601 UTC, after start_time.
period_secConcurrentStreamsPeriodSecAggregation period: 60, 3600, or 86400. Also caps the window length the server accepts (7 days for 60).
kindConcurrentStreamKindstt for Speech-to-Text sessions, tts for Text-to-Speech.

Returns

GetConcurrentStreamsHistoryResponse

Raises

  • SonioxAPIError When the API returns an error.

AsyncAuthAPI

Constructor

AsyncAuthAPI(client: AsyncSonioxClient)

Parameters

ParameterTypeDescription
clientAsyncSonioxClientSoniox client instance.

Returns

None

create_temporary_api_key()

create_temporary_api_key(*, usage_type: TemporaryApiKeyUsageType = 'transcribe_websocket', expires_in_seconds: int = 5 * 60, client_reference_id: str | None = None, single_use: bool | None = None, max_session_duration_seconds: int | None = None) -> CreateTemporaryApiKeyResponse

Create a temporary API key.

Performs a POST request to /auth/temporary-api-key.

The API key needs the Temporary API keys permission and the permission for the service in usage_type. See API key permissions.

Parameters

ParameterTypeDescription
usage_typeTemporaryApiKeyUsageTypeIntended usage of the temporary API key.
expires_in_secondsintDuration in seconds until the temporary API key expires
client_reference_idstr | NoneOptional tracking identifier string. Does not need to be unique
single_usebool | NoneWhen true, restricts the temporary API key to a single use.
max_session_duration_secondsint | NoneMaximum connection duration in seconds for WebSocket and TTS HTTP streaming endpoints.

Returns

CreateTemporaryApiKeyResponse

Raises

  • SonioxPermissionDeniedError When the API key lacks one of those permissions.
  • SonioxAPIError When the API returns another error.

AsyncSonioxWebhooksAPI